- May
- 13,604
- 201
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.
GREP.EXE too.
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.
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.