Loading ...
Sorry, an error occurred while loading the content.

Matching Across Lines

Expand Messages
  • Scott LaBounty
    I have a file that looks like: SI: data SI: data SI: data SK: data SK: data SK: data SK: data SI: data SK: data etc. I m trying to get a regular expression
    Message 1 of 3 , Oct 1, 2003
    • 0 Attachment
      I have a file that looks like:

      SI: data
      SI: data
      SI: data
      SK: data
      SK: data
      SK: data
      SK: data
      SI: data
      SK: data

      etc.

      I'm trying to get a regular expression that will grab all of the
      adjacent SI or SK lines (i.e. the first two SI: lines as a match).

      Any thoughts?

      Thanks,

      Scott LaBounty
      Nexa Tehchnologies, Inc.
    • Antoine J. Mechelynck
      ... Hm... Let s give it a try... What about... (^S[IK] ).*$ ( 1.*$ )* (Untested). Match start-of-lline + SI or SK, then 0 or more characters, then
      Message 2 of 3 , Oct 1, 2003
      • 0 Attachment
        Scott LaBounty <slabounty@...> wrote:
        > I have a file that looks like:
        >
        > SI: data
        > SI: data
        > SI: data
        > SK: data
        > SK: data
        > SK: data
        > SK: data
        > SI: data
        > SK: data
        >
        > etc.
        >
        > I'm trying to get a regular expression that will grab all of the
        > adjacent SI or SK lines (i.e. the first two SI: lines as a match).
        >
        > Any thoughts?
        >
        > Thanks,
        >
        > Scott LaBounty
        > Nexa Tehchnologies, Inc.

        Hm... Let's give it a try... What about...

        \(^S[IK]\).*$\(\1.*$\)*

        (Untested). Match start-of-lline + SI or SK, then 0 or more characters, then
        end-of-line, then zero or more of (first match plus anything to
        end-of-line).

        Regards,
        Tony.
      • bps8@daimlerchrysler.com
        ... How about this one... ^ (.. ):.* _$ ( n 1:.* _$ ) + Brett S.
        Message 3 of 3 , Oct 1, 2003
        • 0 Attachment
          > I have a file that looks like:
          >
          > SI: data
          > SI: data
          > SI: data
          > SK: data
          > SK: data
          > SK: data
          > SK: data
          > SI: data
          > SK: data
          >
          > etc.
          >
          > I'm trying to get a regular expression that will grab all of the
          > adjacent SI or SK lines (i.e. the first two SI: lines as a match).
          >
          How about this one...

          ^\(..\):.*\_$\(\n\1:.*\_$\)\+

          Brett S.

          > Any thoughts?
          >
          > Thanks,
          >
          > Scott LaBounty
          > Nexa Tehchnologies, Inc.
        Your message has been successfully submitted and would be delivered to recipients shortly.