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

Find, replace, find in files, replace in files, regular expressions

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

Postby Skeeve » Mon Aug 04, 2008 5:29 am

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!
Skeeve
Newbie
 
Posts: 4
Joined: Mon Aug 04, 2008 4:42 am

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

Postby pietzcker » Mon Aug 04, 2008 5:55 am

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?
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

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

Postby Skeeve » Mon Aug 04, 2008 7:20 am

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 ;)
Skeeve
Newbie
 
Posts: 4
Joined: Mon Aug 04, 2008 4:42 am

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

Postby pietzcker » Mon Aug 04, 2008 7:56 am

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
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

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

Postby Skeeve » Mon Aug 04, 2008 9:12 am

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...
Skeeve
Newbie
 
Posts: 4
Joined: Mon Aug 04, 2008 4:42 am

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

Postby pietzcker » Mon Aug 04, 2008 9:52 am

Well, there is a "Find in Files" command in the Search menu where you can specify a directory. That works with regular expressions, too.
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

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

Postby Skeeve » Tue Aug 05, 2008 3:34 am

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

THANKS! Works fine!
Skeeve
Newbie
 
Posts: 4
Joined: Mon Aug 04, 2008 4:42 am


Return to Find/Replace/Regular Expressions