作者: | 来源:互联网 | 2023-10-13 16:00
ImtryingtoextractthetextBetClicfromthisstringpopup_siteinfo(this,clickbetclic,373
I'm trying to extract the text BetClic
from this string popup_siteinfo(this, '/click/betclic', '373', 'BetClic', '60€');
我正在尝试从这个字符串popup_siteinfo中提取文本BetClic(这,'/ click / betclic','373','BetClic','60€');
I wrote a simple regex that works on Regex Tester but that doesn't work on Java.
我写了一个简单的正则表达式,适用于Regex Tester,但不适用于Java。
Here's the regex
这是正则表达式
'\d+', '(.*?)'
here's Java output
这是Java输出
Exception in thread "main" java.lang.IllegalStateException: No match found
at java.util.regex.Matcher.group(Matcher.java:485)
at javaapplication1.JavaApplication1.main(JavaApplication1.java:74)
Java Result: 1
and here's my code
这是我的代码
Pattern pattern = Pattern.compile("'\\d+', '(.*?)'");
Matcher matcher = pattern.matcher(onMouseOver);
System.out.print(matcher.group(1));
where the onMouseOver
string is popup_siteinfo(this, '/click/betclic', '373', 'BetClic', '60€');
其中onMouseOver字符串是popup_siteinfo(this,'/ click / betclic','373','BetClic','60€');
I'm not an expert with regex, but I'm quite sure that mine isn't wrong at all!
我不是正则表达式的专家,但我很确定我的一点也不错!
Suggestions?
建议?
2 个解决方案