Home  >  Article  >  Backend Development  >  php regular Chinese

php regular Chinese

WBOY
WBOYOriginal
2016-08-04 09:19:491082browse

php matches Chinese with regular expression

<code>1.用.+ 可以匹配到一个以上的中文吗?
2.用这样的 '/你好,哈哈/' 去匹配中文会不会出现问题?</code>

Because I don’t know much about regular expressions, I would like to ask if there will be any encoding problems when matching regular expressions with Chinese characters?

Reply content:

php matches Chinese with regular expression

<code>1.用.+ 可以匹配到一个以上的中文吗?
2.用这样的 '/你好,哈哈/' 去匹配中文会不会出现问题?</code>

Because I don’t know much about regular expressions, I would like to ask if there will be any encoding problems when matching regular expressions with Chinese characters?

  1. can match

  2. Using /Hello, haha/, this will only match /Hello, haha/this.... because the two slashes before and after will be treated as normal content..

There are also problems with Chinese encoding. Just like if I use unicode characters to match Chinese with ordinary str type content in Python, it won’t match. I just need to cache the unicode encoding of the content

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn