Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by JavaFan (Canon)
on Jan 12, 2009 at 21:03 UTC ( [id://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]"}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-03-29 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found