Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: regex help

by AnomalousMonk (Abbot)
on Oct 06, 2013 at 03:27 UTC ( #1057102=note: print w/ replies, xml ) Need Help??


in reply to regex help

(Further to kcott's reply:)

kelscat18: Not only does the substitution you show in the OP select the wrong strings when used with grep, it changes them and also changes strings in the input array.

>perl -wMstrict -le "my @lines = qw(aaa 111 a2a2 a2==a2 aa==aa); printf '@lines before: '; printf qq{'$_' } for @lines; print ''; ;; my @words = grep(s/[^a-zA-Z0-9]/ /g, @lines); printf '@lines after: '; printf qq{'$_' } for @lines; print ''; printf '@words: '; printf qq{'$_' } for @words; print ''; " @lines before: 'aaa' '111' 'a2a2' 'a2==a2' 'aa==aa' @lines after: 'aaa' '111' 'a2a2' 'a2 a2' 'aa aa' @words: 'a2 a2' 'aa aa'


Comment on Re: regex help
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2015-07-02 04:51 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 (27 votes), past polls