http://qs321.pair.com?node_id=519948


in reply to Using regex to match double letters, and only double letters

I like using POSIX character sets when they're applicable because they will "work" nicely with the locale and utf8 pragmas, and Unicode. When you see [a-zA-Z] in code, you're looking at code that probably won't play nice with locales. A good way to accommodate locales is POSIX character classes. So re-written with that in mind, you have this:

print "Match!\n" if $string =~ m/([[:alpha:]])\1/; # Probably good.

...instead of the possibly problematic:

print "Match!\n" if $string =~ m/([a-zA-Z])\1/; # Maybe bad!

Dave