Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Modern best practices for multilingual regexp alphabetical character matching?

by JavaFan (Canon)
on Jan 12, 2009 at 21:03 UTC ( #735807=note: print w/ replies, xml ) Need Help??


in reply to Modern best practices for multilingual regexp alphabetical character matching?

The data I'm working with will all be UTF-8, if that makes a difference.
That makes a huge difference. \w will match just the 26 letters (both cases), 10 digits and the underscore if your strings aren't in UTF-8 format (unless you have a locale). Otherwise, it will match anything that's a Unicode letter, Unicode digit or underscore.

However, since there's this dependency on whether the string you match against is in UTF-8 format or not, I'd shy away from UTF-8. Instead, use \p{L} which will match any character the Unicode standard says is a letter. So, you'd get:

if (/^(\p{L}+)$/) {say "found [$1]"}


Comment on Re: Modern best practices for multilingual regexp alphabetical character matching?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://735807]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2015-07-05 16:08 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 (67 votes), past polls