Tips: Detect text contains duplicate characters

zhaozj2021-02-11  173

Recently, the forum Filter needs to filter some obvious infiltration posts, such as multiple duplicate characters, where I use regular expressions to filter, the programs are as follows: 3, I think repeat final static pattern p = pattern.compile (". ) // 1 {3,} "); public static boolean containsrepetchars (string txt) {matcher m = p.matcher (txt); if (m.find ()) return true; else returnaf false;} is a static method Can be used as a tool. The specification of the number of repeated characters can be specified in the expression.

转载请注明原文地址:https://www.9cbs.com/read-5786.html

New Post(0)