|
|
| Perl-Sensitive Sunglasses | |
| PerlMonks |
Re: One-liner for Matching a Regex in a Directory of Filesby davido (Bishop) |
| on Jan 11, 2004 at 06:00 UTC ( #320431=note: print w/ replies, xml ) | Need Help?? |
|
I happen to like the following one liner because its output is the entire line that matches, which provides context.
In that one liner, any line that contains a four letter capitalized word starting with M, the whole line will print, so you can get a good idea of where it appears in the file. Also, the line number within the file is printed for added clarity. The regex uses the \b "word boundry" assertion at both sides of the M[A-Z]{3} construct, to ensure that four and only four letters will trigger a match.
Dave
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||