Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect Chinese character with punctuation in regex?

I have noticed that there are question asked on how to detect Chinese character with regex. These are some question I read on stackoverflow:

Php check if the string has Chinese chars

detecting chinese characters in php string

And some article outside stackoverflow:

http://www.regular-expressions.info/unicode.html - unicode script

Basically they suggest using either \p{Han}+ or [\x{4e00}-\x{9fa5}]+.* to detect Chinese character. Is there a way to detect Chinese punctuation mark as well?

Some example (but not all) of Chinese punctuation mark: :?。,《》「」『』-()【】

like image 210
cytsunny Avatar asked Jan 06 '16 09:01

cytsunny


1 Answers

[\u4e00-\u9fa5] works for me in VSCode, the other suggested solutions don't. I stumbled on the solution here, which is a online regex interpreter: http://tool.chinaz.com/regex/

like image 109
Leon Avatar answered Nov 09 '22 12:11

Leon