14,953
edits
mNo edit summary |
|||
| Line 198: | Line 198: | ||
==== Find Chinese Characters in Google Sheets ==== | ==== Find Chinese Characters in Google Sheets ==== | ||
Example: If A2 contains any Chinese character, display “Chinese”, otherwise display “English”: | Example: If cell {{kbd | key=A2}} contains any Chinese character, display “Chinese”, otherwise display “English”: | ||
<pre>=IF(REGEXMATCH(A2, "[\一-\龥]"), "Chinese", "English")</pre> | <pre>=IF(REGEXMATCH(A2, "[\一-\龥]"), "Chinese", "English")</pre> | ||
<span id="find-chinese-characters-in-mysql"></span> | <span id="find-chinese-characters-in-mysql"></span> | ||
Extract non-ASCII characters (such as Chinese, Japanese, emoji, etc.) from cell {{kbd | key=A2}} | |||
<pre> | |||
=IF(ISERROR(REGEXEXTRACT(A2, "[^\x00-\x80]+")), "", REGEXEXTRACT(A2, "[^\x00-\x80]+")) | |||
</pre> | |||
Explanation of regular expression {{kbd | key=<nowiki>[^\x00-\x80]+</nowiki>}} | |||
* {{kbd | key=<nowiki>[\x00-\x80]</nowiki>}}: Represents the ASCII character range (character codes 0-128). (1) Standard ASCII range: 0-127 ({{kbd | key=<nowiki>0x00-0x7F</nowiki>}} aka * {{kbd | key=<nowiki>[\x00-\x7F]</nowiki>}})<ref>[https://www.commfront.com/pages/ascii-chart ASCII Chart – CommFront]</ref> (2) Character 128 (({{kbd | key=<nowiki>0x80</nowiki>}}) is actually the first character in the extended ASCII range, not part of the original ASCII standard.<ref>[https://en.wikipedia.org/wiki/UTF-8 UTF-8 - Wikipedia]</ref><ref>[https://en.wikipedia.org/wiki/Control_character Control character - Wikipedia]</ref> | |||
* {{kbd | key=<nowiki>[^...]</nowiki>}}: Means "not" these characters | |||
* {{kbd | key=<nowiki>+</nowiki>}}: Means one or more | |||
Overall meaning: Matches one or more non-ASCII characters | |||
==== Find Chinese Characters in MySQL ==== | ==== Find Chinese Characters in MySQL ==== | ||