How does php determine whether a string contains four consecutive characters?

Source: Internet
Author: User
How does php determine whether a string contains four consecutive characters: PHPcode & lt ;? Php $ strphp: how to judge whether a string contains four consecutive characters: me and me; $ strphp: how to judge whether a string contains four consecutive characters: me, sssssssss; if (preg_match (& quot ;(.) \ 1 {3 ,}& quot;, $ str) {echo has continuous php. how can I determine whether a string contains four consecutive characters?
PHP code
  

  


The above code can only judge English and Chinese characters are unavailable. Is there any other method?

------ Solution --------------------
UTF-8 Chinese characters

If (preg_match ("/([\ x {4E00}-\ x {9FFF}]) \ 1 {3,}/u", $ str )){
------ Solution --------------------
UTF-8
Preg_match ("/(.) \ 1 {3,}/u", $ str)

For gbk
Preg_match ("/([\ x80-\ xff]. |.) \ 1 {3,}/", $ str)

A string cannot have two types of encoding at the same time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.