At 9:18 PM -0400 3/29/11, Chas. Owens wrote:
It is important to note that \d doesn't match what you think it does. Starting with Perl 5.8, \d matches and digit character. This includes characters such as "\x{1815}" (Mongolian digit five). To match the ASCII digit characters you must use [0-9]:
I have heard this advice before, and it just sounds silly to me. I deal exclusively with ASCII characters, so \d will only match the characters '0' through '9'. If any UTF characters have crept into my data unknowingly, then I have a bigger problem than too many matches. If I am dealing with Monogolian characters or with any other set of UTC characters, then I certainly want \d to match them as well. There is a good reason why the set of characters matched by \d was expanded.
In other words, I see no reason to avoid using \d. Advising beginners to avoid the use of \d is just plain wrong. Can you provide any example of a situation where something bad will happen from using \d?
The statement "To match the ASCII digit characters you must use [0-9]" is wrong. I believe you meant to say "To match the ASCII digit characters and only those characters, you must use [0-9]".
-- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/