in reply to Re^2: Matching range of text with another string in between
in thread Matching range of text with another string in between

Does CAS* always start at the beginning of a line? And does the CAS* line have any trailing blanks?

  • Comment on Re^3: Matching range of text with another string in between

Replies are listed 'Best First'.
Re^4: Matching range of text with another string in between
by periodicalcoder (Novice) on Apr 22, 2016 at 18:18 UTC
    I tried changing \n to \r\n as follows, but it still returned the entire contents:
    perl -ne "BEGIN{ $/ = qq(\r\nCAS*\r\n) } /00003/ and print" "filename"
    Yes, CAS* always starts at the beginning of the line, and those lines do not have any trailing blanks. I want to make sure that the matching entries start with LX* and end with CAS*. I could be wrong but it almost looks like the code above is matching starting with CAS* instead.

      $/ is endofline (see perldoc perlvar). At this point I no longer trust your data file and would use a dump program to verify that the sequence \r\nCAS*\r\n exists in the file.

      Are you sure it is not a Mac file? They have different line endings.

        It looks like I misunderstood your question about the line endings. The file is provided by MediCal and is in the "ANSI ASC X12" format which they also referred to as an "ANSI 835s" file.

        According to Notepadd++ the end of line characters are CR LF. I hope that helps.