How to use php to write a function requires that more than three consecutive identical characters will be filtered into two, and the regular expression will also work! Solution-php Tutorial

Source: Internet
Author: User
How to use php to write a function requires that more than three consecutive identical characters will be filtered into two, and the regular expression will also work! For example, such as "good", "good", "very good, very good", and "very good, very good", ", "Is filtered into", ", such as" ~~~~~~~" Filtered to "~~", Include as many possibilities as possible! I am playing wordpress recently and want to avoid as many spam and meaningless comments as possible ~ ------ Solution --- how to use php to write a function requires that more than three consecutive identical characters will be filtered into two, and the regular expression will also work!
For example, such as "good", "good", "very good, very good", and "very good, very good", ", "Is filtered into", ", such as" ~~~~~~~" Filtered to "~~", Include as many possibilities as possible! I am playing wordpress recently and want to avoid as many spam and meaningless comments as possible ~

------ Solution --------------------
Discussion

Reference:

Echo preg_replace ("/(. +) \ 1 +/is", '$1 $ 1', $ s );

But I don't know ~~~~~~~~~ Why cannot It be processed?

. +? Yes

------ Solution --------------------
Discussion

Reference:

Reference:

Echo preg_replace ("/(. +) \ 1 +/is", '$1 $ 1', $ s );

But I don't know ~~~~~~~~~ Why cannot It be processed?

. +? Yes
Are you kidding?
PHP code
$ S = <TXT
For example, "good, good" is filtered into "good", like "very good, very good, very good "......

------ Solution --------------------
Haha, my memory is okay ....

Http://topic.csdn.net/u/20100302/22/A86F914D-AC19-4955-BC98-768C584EA800.html#r_63678078

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.