Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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:


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)