Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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


Dave


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-08-21 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls