/x does exactly what you think it does; It's "free form" style, where any
non-escaped whitespace is ignored. See perlretut[0], perlop[1], and
perlre[2].

(?<!) is a negative lookbehind; (?!) is a negative lookahead. Meanwhile,
(?<=) is a positive lookbehind, and (?=) is a positive lookahead; They are
all explained in perlre, under Extended Patterns[3] (as well as in Mastering
Regular Expressions and Programming Perl). A look behind says that "this
pattern must match in the text before the position I'm currently in", while
a lookahead says the same, but for the positions further ahead in the
string. They are zero-width assertions like ^ and \b; In fact, \b translates
to (?:(?<=\w)(?!\w)|(?<!\w)(?=\w)), which admittedly is a mouthful.

Your regex should work fine I think, though if you want to be redundant you
could change \d to \p{PosixDigit}, not because it's really needed, but
mostly because Unicode character properties[4] are awesome.

Brian.

[0] http://perldoc.perl.org/perlretut.html
[1] http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators
[2] http://perldoc.perl.org/perlre.html#Modifiers
[3] http://perldoc.perl.org/perlre.html#Extended-Patterns
[4] http://perldoc.perl.org/perluniprops.html

Reply via email to