How Can I Run a Regex that Tests Text for Characters in a Particular Alphabet or Script?

Posted by Eli on Stack Overflow See other posts from Stack Overflow or by Eli
Published on 2011-11-30T22:10:29Z Indexed on 2011/12/01 1:52 UTC
Read the original article Hit count: 141

Filed under:
|

I'd like to make a regex in Perl that will test a string for a characters in a particular string. This would be something like:

$text =~ .*P{'Chinese'}.*

Is there a simple way of doing this, for English it's pretty easy by just testing for [a-zA-Z], but for a script like Chinese, or one of the Japanese scripts, I can't figure out any way of doing this short of writing out every character explicitly, which would make for some very ugly code. Ideas? I can't be the first/only person that's wanted to do this.

© Stack Overflow or respective owner

Related posts about regex

Related posts about perl