且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换除一个之外的所有特殊字符

更新时间:2023-02-19 22:45:25

如果你想匹配除 \w - 以外的所有字符,你可以使用:

If you want to match all the characters except \w and - you can use:

[^\w-]

例如:

str.replaceAll("[^\\w-]+", " ")