How to find 2 subjects with max. 72 rows between them?

How to find 2 subjects with max. 72 rows between them?

4
NewbieNewbie
4

    Aug 04, 2008#1

    Hi,

    my problem: I need to find 2 subjects in a large text file. Only if there are less then 72 lines between them, it is a hit.
    Is this possible with UE regular expressions??

    THX!

    236
    MasterMaster
    236

      Aug 04, 2008#2

      I'd say you'll need Perl regular expressions for this.

      By "line", you mean a CRLF delimited line? I.e., ignoring word wrap?
      And are these search terms the only thing on the line or are they just part of the line?
      What exactly do you want to match? All the lines between the two search terms?

      4
      NewbieNewbie
      4

        Aug 04, 2008#3

        Hi pietzcker,
        By "line", you mean a CRLF delimited line? I.e., ignoring word wrap?
        Yes and yes!
        And are these search terms the only thing on the line or are they just part of the line?
        The two terms are parts of differnt lines.
        What exactly do you want to match? All the lines between the two search terms?
        The textfile contains tons of "bills", all our accounts of the last years. It is exported from our "erp software" (the software is old, "self" programmed and is not using a database ;-) ) in "print ready" ascii format for our matrix printer, 72 lines per account.
        In some cases it is helpfull to look if a customer (identified with his customer number -> term 1) bought a product (term 2) in history. If both terms will be found in a distance of max. 72 lines, you got a 99% hit. Just look if the terms both are on the same account, this is easy by scrolling a few lines in UE.
        Hope you understand my description ;)

        236
        MasterMaster
        236

          Aug 04, 2008#4

          OK, first attempt. If this doesn't work, please send a sample of your data. You need to enable Perl regular expressions for this to work (UE V12+ required; check the readme topic of this forum for more info if necessary):

          Search for
          TERM1.*\r\n(?:.*\r\n){0,72}.*TERM2

          This will match and select everything from TERM1 up until TERM2 as long as there are no more than 72 lines between them. Be careful to escape special regex characters. E.g., if you want to match 1.000, use 1\.000 as search term...

          HTH,
          Tim

          4
          NewbieNewbie
          4

            Aug 04, 2008#5

            GREAT! That works great! Thanks a lot!!!

            Level 1 was easy for you ;)
            Level 2 ( :-D )
            Is it possible to do that search over all files in a directory? My boss told me, that our account export is splitted in 75MB files (each is containing 10000 accounts). Lots of files... :-(
            UE can search over "all open files", but there are a few hundred...

            236
            MasterMaster
            236

              Aug 04, 2008#6

              Well, there is a "Find in Files" command in the Search menu where you can specify a directory. That works with regular expressions, too.

              4
              NewbieNewbie
              4

                Aug 05, 2008#7

                Upps... I have to open my eyes ;)

                THANKS! Works fine!