Prevent consecutive meaningless characters from occurring in JS or PHP
習慣沉默
習慣沉默 2017-06-29 10:08:06
0
1
733

Users often send many meaningless characters such as "Ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"

Is there any way to prohibit it? Either js or php is fine.

Thanks

習慣沉默
習慣沉默

reply all(1)
我想大声告诉你

Regular judgment

var re = /(.){3,}/u;  // 匹配同一个字符4次以上
re.test(str); // true = 同一字符4次或以上
preg_match('/(.){3,}/u', $str); // 1 = 同一个字4次或以上

Send a JS test picture:

Note:

    The
  1. u

    modifier after the regular is used to support Unicode wide characters

  2. {3,} means matching 3 times or more. Since the previous (.) has already been matched once, the entire limited number is 1 greater than this number. In addition, this number can be changed according to your own needs.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!