Multi-line matches with regular expressions (pcregrep)
Monday, June 26th, 2006Proofreading my thesis I had the following problem: Find all occurrences of “alert processing system” (should be “alert-processing system”), which can span over multiple lines.
I found out (thanks Diego!) a number of ways of doing this.
Writing my own perl program and defining
INPUT_RECORD_SEPARATOR($/)Using
agrep, in which I can use -d ‘delim’ as the separator. The advantage of agrep is that is can also find mispelled words (with a certain editing distance).Using
pcregrep!
I chose the last solution as it is the simplest one:
pcregrep -Mi 'alert\s+processing\s+system' <file>
IT WORKS!