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.
当我在 String 类的 matches() 方法中使用此正则表达式时,出现编译错误。有人知道我在这里做错了什么吗?谢谢
String email = "this@that.com"; System.out.println(email.matches("^(.+@.+\.\\w{2,4})$"));
.带有两个反斜杠的转义期\\.java 中支持的有效转义序列是 \b \t \n \f \r \" \' \\
.
\\.
\b \t \n \f \r \" \' \\
System.out.println(email.matches("^(.+@.+\\.\\w{2,4})$"));
或者:
将其包含在\\Q和\\E
\\Q
\\E
\\Q.\\E