Regex end of line in issue in SSIS search replace

  • Coming from a Unix background in the 80s, I've grown to rely on regular expressions to write code. Frequently, I perform tasks such as taking a list and inserting quotes and commas. in SSIS, when I match to  the end of a line using either \n or $, the insert is always place after the line. eg-
    one
    two
    three

    find: $
    replace: ',

    results in::
    one
    ',
    two
    ',
    three
    ',

    Why does this not work as expected? is there  a workaround?

    Thanks,
    David

  • In the Windows world, text files are not generally the same as in the Unix world, as they are generally terminated with CR/LF, which is 0D0A hex, as opposed to the Unix standards of just CR, which is 0D hex, or just LF, which is 0A hex.   Interpretation of line endings is also context sensitive.   Notepad, for example, isn't going to properly display the lines of a Unix-based file, but Notepad++ can do it, but may need to be told to do so.   Seeing SSIS do something you're not used to is not surprising, but does have to be accounted for, and SSIS is anal enough that you really need to know exactly what your line endings are in order to effectively manipulate the text within.   Also, given the desire to place additional text at the end of a line, I might consider splitting the string into lines first, and not necessarily using Regex as a goto methodology.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply