Php Regular Expression Matching. output with the same 3 characters: yes

Source: Internet
Author: User
Evaluate the php regular expression to match the output with three identical characters. for example, $ str = "I am"; there are three identical words echo & nbsp; 'yes '; $ str2 = "I am a great guy"; there are three identical words echo & nbsp; 'yes'; $ str3 = "12333456 "; there are 3 identical words echo & nbsp; 'Ye: php regular expression matching 3 identical output yes
For example
$ Str = "me and I ";

There are 3 identical words
Echo 'yes ';


$ Str2 = "I am a great guy ";

There are 3 identical words
Echo 'yes ';




$ Str3 = "12333456 ";

There are 3 identical words
Echo 'yes ';


I don't know what the character is! It must contain three identical characters.
Method! Best Regular Expressions
------ Solution --------------------
$ Str2 = "I am a great guy ";
If (preg_match ('/(. +) \ 1 {2}/', $ str2 ))
Echo 'yes ';

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.