[英]How can I check if a string contains (number)
I need to test if a string contains brackets with a number in the middle 我需要测试一个字符串是否包含中间带有数字的方括号
Fight Club (2008) -> true 搏击俱乐部(2008)-> true
Sick (Documentary 2008) -> false 生病(纪录片2008)->错误
I have this but i cant test it because I can;t compile. 我有这个,但是我不能测试,因为我不能编译。 I get an error "Invalid escape sequence (valid ones are \\b \\t \\n \\f \\r \\" \\' \\ )"
我收到一个错误“无效的转义序列(有效的是\\ b \\ t \\ n \\ f \\ r \\” \\'\\)”
if(title.matches("\\((\d)\\)")){
}
You can use: 您可以使用:
if(title.matches(".*?\\(\\d+\\).*")){
}
Remember that String#matches
expects to match complete input. 请记住,
String#matches
期望匹配完整的输入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.