FFIND and multi-line regular expressions

May 20, 2008
11,285
95
Syracuse, NY, USA
I never knew (GRRRR!) that FFIND can handle multi-line regular expressions (so can Gnu GREP.EXE, which I also didn't know). Either one would have come in handy many times over many years. Rex, is it by design and reliable? If so, the help should brag about it!

In testing I randomly wrote one of 4 lines, 32768 times, to a file. The lines were "My", "dog", "has", and "fleas.". I wondered how often those lines appeared consecutively (probability predicts 128 on average). This did it.

Code:
v:\> ffind /u /v /e"My\r\ndog\r\nhas\r\nfleas" doggy.txt | tail /n5
  125 lines in      1 file

GREP.EXE too.

Code:
v:\> g:\gnu\grep -c -P "My\ndog\nhas\nfleas." doggy.txt
125

I like how FFIND (and GREP) counts the matches (instead of the 500 lines that include the matches).

You can also do it with FFIND /T. And while I have no particular preference, GREP.EXE, FFIND /T, and FFIND /E differ in an interesting way.

Code:
v:\> ffind /v /k /m /e"My\r\ndog\r\nhas\r\nfleas" doggy.txt | tail /n4
My
My
My
My

v:\> ffind /v /k /m /t"My^r^ndog^r^nhas^r^nfleas" doggy.txt | tail /n4
fleas.
fleas.
fleas.
fleas.

v:\> g:\gnu\grep -P "My\ndog\nhas\nfleas." doggy.txt | tail /n4
My
dog
has
fleas.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
It also works with /T and in pipes ... also by design and reliable? The /E version is much faster!

Code:
v:\> timer & (do i=1 to 100 (ffind /v /k /m /e"My\r\ndog\r\nhas\r\nfleas" doggy.txt)) > nul & timer
Timer 1 on: 23:40:38
Timer 1 off: 23:40:39  Elapsed: 0:00:01.40

v:\> timer & (do i=1 to 100 (ffind /v /k /m /t"My^r^ndog^r^nhas^r^nfleas" doggy.txt)) > nul & timer
Timer 1 on: 23:42:39
Timer 1 off: 23:42:44  Elapsed: 0:00:04.40
 
Similar threads
Thread starter Title Forum Replies Date
J ffind does not find files Support 4
D ffind hangs on large file Support 18
Alpengreis ffind dialog (/W) problem Support 4
vefatica FFIND, temp files? ... not deleted? Support 0
S FFIND text that includes " Support 7
D ffind /e hangs Support 7
vefatica FFIND needs work Support 12
Joe Caverly Multiple Text Searches at once using FFIND or TPIPE Support 4
Kachupp FFIND TPIPE Support 9
Gamegod ffind bug with chinese Support 2
vefatica Make FFIND a bit more friendly? Support 14
M Trying to use ffind with a @file.lst doesn't work Support 4
vefatica Corruption from FFIND? Support 5
vefatica FFIND /S and System32? (and an OT mystery) Support 14
T FFind - can we display n number of lines after the find? Support 2
vefatica Help nit (FFIND and DIR with /S) Support 0
R ffind not setting %_ffind_ vars if /f is used Support 7
M FFIND wordA AND wordB Support 4
vefatica FFIND and _? Support 1
B Fixed FFIND doesn't find last character in file without CR/LF at EOF Support 1
dcantor How to make line numbers fixed width in FFIND Support 11
vefatica FFIND /S, find directory with specified name? Support 7
D Why doesn't ffind find directory? Support 3
C FFind /w works but FFind /= doesn't? Support 2
vefatica FFIND goes crazy Support 8
Stefano Piccardi TCC 13 vs. TCC 14 different FFIND /E"d$" output Support 1
Steve Pitts How to? FFIND, regular expressions and double quotes Support 4
vefatica FFIND /S in my profile directory Support 2
A How to? Pass output from ffind to another command in a BTM file Support 5
Phileosophos Can FFIND match file names with a regular expression? Support 19
vefatica FFIND and size ranges Support 1
R How to use ffind to find older files? Support 9
J How do I - ffind - with multiple items Support 10
M FFIND and LIST does not work for UTF-8 fles Support 10
C FFIND ERRORLEVEL Support 2
L FFIND no result display Support 10
H Directory wildcards not working with ffind Support 3
D ffind and directories Support 2
Stefano Piccardi detecting BOM, FFIND multibyte regex Support 18
dcantor FFIND syntax -- is /E"regex" /X supported? Support 2
S FFIND and quoted strings Support 4
S FFIND /E"reg exp" : not case insensitive Support 4
J Problem with FFIND Support 1
D How to use multi-line DO to loop through first level directory names Support 5
rps Multi-column DIR /v not displaying all files. Support 5
D xp support and multi-license Support 5
T WAD Difference between TCC and CMD in handling multi-command lines Support 6
V V - Multi-Pane File Manager Support 14
Daniel P How to Purchase a Multi-System License for TCC? Support 2
B Alias with multi line definitions not assigned Support 6

Similar threads