Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Regex to remove data

by rjt (Deacon)
on Nov 06, 2012 at 17:10 UTC ( #1002530=note: print w/ replies, xml ) Need Help??


in reply to Regex to remove data

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.txt

Of 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]+$/ }


Comment on Re: Regex to remove data
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002530]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2015-07-08 03:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls