Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Pattern match

by davido (Cardinal)
on Jan 17, 2006 at 21:15 UTC ( [id://523841]=note: print w/replies, xml ) Need Help??


in reply to Pattern match

The problem you have is that you're misunderstanding quantification of metacharacters, and metacharacters themselves. \w matches one "word" character, not a bunch of characters. \w also does not match "5.0.29.0", for example. Also, '.' matches any character except for newline, so it must be escaped, as in \. if you want it to be seen as a literal character in the pattern match. You probably want something more like this:

m/Rescue21.+patch.+DiffList\.txt/

...or...

{ local $_ = $mystring; if( /Rescue21/ && /patch/ && /DiffList.txt/ ) { #.... } }

...though the latter would give a false positive if the filename looked like "DiffList.txt_patch_Rescue21". In other words, the latter solution wouldn't reject matches where the keywords appeared out of order.


Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-24 19:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found