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

Re^2: Regex word options

by choroba (Cardinal)
on Nov 01, 2012 at 09:11 UTC ( [id://1001782]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex word options
in thread Regex word options

The || does not work inside a regular expression (well, it does, but it matches anything). Add some more testing strings. Use single| inside a regex, or use two regexes connected by ||.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^3: Regex word options
by ww (Archbishop) on Nov 04, 2012 at 00:11 UTC
    Alas, I erred.

    The honorable choroba is correct; blame simple carelessness; intermittent, inadequate internet access in my second consecutive month on the road and my plain errror for the wrongful use of ||. As written above it should be a single Vbar; as choroba notes, it could also be written as:

    #!/usr/bin/perl use 5.10.0; my @work=("I Arranged a meet.", "Transcribe this", "Shud Not MATCH"); for $work(@work) { if (($work =~ /Transcribe/) || ($work =~ /Arranged/) ) { say $work; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-18 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found