Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Quick Regex trouble

by Not_a_Number (Parson)
on Jul 16, 2013 at 21:47 UTC ( #1044664=note: print w/ replies, xml ) Need Help??


in reply to Quick Regex trouble

kennethk++ is right. I'd just like to post a word of warning concerning this part of your regex:

[[:alnum:]\.-:]+

Firstly, you don't need to escape the dot in a character class (but there's nothing stopping you from doing so...). More importantly, the sequence

\.-:

(with or without the backslash) in a character class means "any character between '.' (dot) and ':' (colon) (inclusive)".

As it happens, the only things in the ASCII (or UTF, or whatever) table between these two characters are the forward slash and the digits 0-9 (the latter being included, of course, in [:alnum:]).

The point is, that if you want to put a literal hyphen in a character class, you should generally put it at the very beginning or the very end, or else escape it with a backslash.

Update: Typos (yawn)


Comment on Re: Quick Regex trouble
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2014-11-24 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (135 votes), past polls