|
|
| P is for Practical | |
| PerlMonks |
Re: Regex to remove databy rjt (Pilgrim) |
| on Nov 06, 2012 at 17:10 UTC ( #1002530=note: print w/ replies, xml ) | Need Help?? |
|
It looks like you want to remove lines that (optionally) contain spaces in addition to uppercase. This one-liner will do the trick: perl -ne 'print unless /^[A-Z\s]+$/' <in.txt >out.txtOf course if you are including this in a larger Perl program, you can just nab the regex out of that, and use it in a loop construct of some kind. For example: while (<>) { print if !/^[A-Z\s]+$/ }
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||