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

Help on regex with multiple lines

Expand Messages
  • René R. Nygaard
    Hello There I m would like to find a section in our log-files starting with date: [function]: -----------Start-------------- then several lines where one
    Message 1 of 2 , Jul 26 3:56 AM
    • 0 Attachment
      Hello There

      I'm would like to find a section in our log-files starting with
      date: [function]: -----------Start--------------
      then several lines where one contains SIQKI
      then several lines again, and finally a line containing
      date: [function]: ----------End---------------

      The line-count between start and end is not the same, the order of the lines
      between the start and end are random.
      I would like to use a reg-exp somehow to extract all sections like the one
      above.
      I'm having serious problems with the multi-lines, and [.\n]* does not seem
      to work.

      Can this be achieved at all ???

      Thanks in advance
      - Ren� R. Nygaard
    • DZ-Jay
      ... Since EditPlus s regexp engine is a greedy bastard, I can t seem to get it to get only one section at a time :( I go so far as this: date: [function ]:
      Message 2 of 2 , Jul 27 3:02 AM
      • 0 Attachment
        Some time around 07/26/2004 06:56:15, I think I heard René R. Nygaard say:
        > Hello There

        > I'm would like to find a section in our log-files starting with
        > date: [function]: -----------Start--------------
        > then several lines where one contains SIQKI
        > then several lines again, and finally a line containing
        > date: [function]: ----------End---------------

        > The line-count between start and end is not the same, the order of the lines
        > between the start and end are random.
        > I would like to use a reg-exp somehow to extract all sections like the one
        > above.
        > I'm having serious problems with the multi-lines, and [.\n]* does not seem
        > to work.

        > Can this be achieved at all ???

        Since EditPlus's regexp engine is a greedy bastard, I can't seem to get it to get only one section at a time :( I go so far as this:

        date: \[function\]: -+Start-+\n(.+\n)*date: \[function\]: -+End-+\n

        The only way I can think of getting it to match only one section is to reject a line starting a section. But since there is no NOT logic expressions in EditPlus' regexp engine, we can only reject character ranges. So, for example, if you are absolutely *sure* that the lines between "Start" and "End" do not contain a dash (-) character, you can do something like this:

        date: \[function\]: -+Start-+\n([^-]*\n)*date: \[function\]: -+End-+\n

        This works, like I said, *if* the dash character occurs only in the "Start" and "End" lines. Optionally you can choose a different character, of course, as long as it doesn't exist in the random lines between "Start" and "End".

        As another option, do what some of us do: Install Perl in your computer (why haven't you so far? :) and make scripts which you can run as text filters or macros from EditPlus.

        I hope this helps.
        dZ.
      Your message has been successfully submitted and would be delivered to recipients shortly.