/** * @Author :tc * @Date :Created in 4:06 PM 2023/12/26
*/ public class RegularUtil { public static final String regex = "[\\u4e00-\\u9fa50-9]"; /** * 提取字符串中的中文和数字 * @author feiyang * @param content * @return java.lang.String * @date 2020/1/3 * @throws */ public static String extractCnAndDigi(String content) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(content); StringBuilder stringBuilder = new StringBuilder(); while(matcher.find()) { stringBuilder.append(matcher.group()); } return stringBuilder.toString(); } }
标签:中文,提取,String,matcher,content,stringBuilder,字符串,public From: https://www.cnblogs.com/cytc/p/17928866.html