简体   繁体   中英

Python Regex Search Chinese/Japanese Characters

Aside from using the Unicode mode (http://xahlee.org/perl-python/regex_split.html) in Python to search Chinese/Japanese characters, is it possible to still search for the said character in case insensitive or sensitive mode? (re.i)

I'm trying to understand why the following do not work:

mystring = 你是我
found    = re.search(你是我, mystring, re.I)
found    = re.search(你是我, mystring)

Chinese and Japanese characters don't have a case, so they are unaffected by the case insensitivity flag. Make sure you are using unicode strings though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM