regex words matching for Chinese and Japanese character

后端 未结 2 1988
名媛妹妹
名媛妹妹 2021-01-20 17:30

I know the pattern to detect if it\'s a string is chinese character but that\'s not what I need. I need to check if the characters is found in a string.

cons         


        
2条回答
  •  梦谈多话
    2021-01-20 17:58

    \b only works on boundary between words and non-words. In case of Chinese, the entire '你说到这是一个测试' is considered a word, so '一个' won't match '你说到这是一个测试' with your regex pattern with \b since '一个' is not at the word boundary of '你说到这是一个测试'. '测试' on the other hand, will match. For Chinese words, a simple substring match is usually enough.

提交回复
热议问题