How to recognize Chinese characters in a string?Hi,I have a problem on regex,
For example:
regex("零件2305wu","[\u4e00-\u9fa5]+")I want to extract the "零件" but the output is "2305".
Thanks!
macOSRe: How to recognize Chinese characters in a string?It seems to have been found.
regex("零件2305wu","[^\x00-\xff]+")
</CODE></PRE></LINGO-BODY><LINGO-SUB id="lingo-sub-654820" slang="en-US" mode="NONE">Re: How to recognize Chinese characters in a string?</LINGO-SUB><LINGO-BODY id="lingo-body-654820" slang="en-US" mode="NONE"><P>Nice! I was going to suggest similar,</P>
<PRE><CODE class=" language-jsl">regex("零件2305wu","[^\x01-\x7f]+")
The characters from x00 to x7F are ASCII; x00 might make a note in the log, so maybe start at x01. Characters from x80 to xFF are similar to ASCII and you might want to leave them out as well. Outside that range is non-ASCII Unicode.
The [ square brackets ] make a character set, and the leading ^ means not in this set. The minus means a range. The + means one or more.
Re: How to recognize Chinese characters in a string?https://www.google.com/search?q=unicode+%E4%B8%80 (4E00) is smaller than
https://www.google.com/search?q=unicode+%EF%A8%A9 (FA29) so it should be a valid range. It matches about 11/16 of the Unicode characters.
{0,} means zero or more, just like *
it appears to work, keeping the first two characters and rejecting the last 6 characters.
Re: How to recognize Chinese characters in a string?tx=regex("零件2305wu","([一-﨩]{0,})");Thanks Experts!