Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 chilling in the Monastery: (7)
As of 2015-07-03 03:26 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 (48 votes), past polls