1.去掉所有字母
s = s.replaceAll(“[a-zA-Z]”,“”);
2.去掉两个字符间的内容
textString = textString.replaceAll(“<img.*?/>”,“”);
3.过滤特殊字符
String regEx=“[<>/”#]“;
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(textString);
textString = m.replaceAll(” ").trim();
4.将三位数的id,批量生成sql语句
查找:([0-9]{3})
替换:insert into tableName (userId,parentId,type) values(110,$1,1);
备注:$1 的含义是引用第一个小括号,如何有第二个小括号就是$2
正则表达式
最新推荐文章于 2025-04-28 17:29:54 发布