Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下
Pattern loPattern = Pattern.compile(someText.toLowerCase(), Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
someText如果有类似的模式,此行将引发异常e[l
someText
e[l
这someText可以包含字符[az][AZ][0-9]!@#$%^&;*()_+=|{}[];:'"<>;,.?/`~§ -
什么是可能的解决方案?
添加Pattern.LITERAL标志,以便元字符不会在表达式中翻译
Pattern.LITERAL
Pattern loPattern = Pattern.compile(someText, Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.LITERAL);