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.