Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 having an uproarious good time at the Monastery: (9)
As of 2015-07-03 11:17 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 (51 votes), past polls