且构网

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

Java正则表达式和美元符号

更新时间:2022-03-22 22:20:52

您需要使用反斜杠( \ $)在正则表达式中转义 $ c $ c>),但作为反斜杠是字符串中的转义字符,你需要转义反斜杠本身。

You need to escape $ in the regex with a back-slash (\), but as a back-slash is an escape character in strings you need to escape the back-slash itself.

您将需要以相同的方式转义任何特殊的正则表达式char,例如使用。。

You will need to escape any special regex char the same way, for example with ".".

String pattern = "/feedback/com\\.navteq\\.lcms\\.common\\.domain\\.poi\\.feedback\\.Review\\$0(.)*";