SoFunction
Updated on 2024-10-29

Example of python determining if a string contains Chinese characters or non-Chinese characters

The compile value in the model can be changed as needed to meet different testing requirements.

# Determine if a text contains Simplified Chinese
import re
zhmodel = (u'[\u4e00-\u9fa5]')  #Check Chinese
#zhmodel = (u'[^\u4e00-\u9fa5]') #Check for non Chinese
contents = u'(2014) Shennan Law Min Er Chu Zi No. 280.'
match = (contents)
if match:
  print(contents)
else:
  print(u'Does not contain Chinese')

The above example of this python to determine whether a string contains Chinese characters or non-Chinese characters is all that I have shared with you, I hope to give you a reference, and I hope you will support me more.