问题匹配的Android正则表达式 [英] Problem matching regex pattern in Android
本文介绍了问题匹配的Android正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图寻找此字符串:
,"tt" : "ABC","r" : "+725.00","a" : "55.30",
有关:
"r" : "725.00"
这是我目前的code:
And here is my current code:
Pattern p = Pattern.compile("([r]\".:.\"[+|-][0-9]+.[0-9][0-9]\")");
Matcher m = p.matcher(raw_string);
我一直在尝试该模式的多种变体,并且匹配没有找到。第二组的眼睛将是巨大的!
I've been trying multiple variations of the pattern, and a match is never found. A second set of eyes would be great!
推荐答案
您正则表达式的实际工作,这几乎是正确的。
Your regexp actually works, it's almost correct
Pattern p = Pattern.compile("\"[r]\".:.\"[+|-][0-9]+.[0-9][0-9]\"");
Matcher m = p.matcher(raw_string);
if (m.find()){
String res = m.toMatchResult().group(0);
}
这篇关于问题匹配的Android正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文