Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Wild card in regular expression

by davido (Archbishop)
on Nov 28, 2012 at 21:09 UTC ( #1006102=note: print w/ replies, xml ) Need Help??

in reply to Wild card in regular expression

* isn't a "wildcard" for Perl regular expressions. Your regex is saying "match and capture 'the' plus zero or more 'r' characters". Consequently, the first 'the' matches.

Try using s/(ther.*)\b/......., for example. "Dot" (.) is the wildcard metacharacter; it matches anything except for a newline, unless you ask Perl to allow it to match the newline too.

Update: Just in case anyone stumbles across this thread while searching for an answer:

Reading perlrequick is a great quick-start to regular expression syntax. Follow it up with perlretut, and then perlre. Additional useful resources include perlop, perlvar, perlrecharclass, perluniprops. But perlrequick is about a half hour of reading for a 70% better understanding of regexes. Each additional document adds a few extra percentage points of knowledge to the foundation that perlrequick builds. ...and of course for the 1000% bonus, "Mastering Regular Expressions" (O'Reilly).


Comment on Re: Wild card in regular expression
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2015-11-28 07:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (739 votes), past polls