为什么此RegEx不能给我任何结果?!
Pattern p = Pattern.compile("(^|\\S*\\s)\\S*est\\S*($|\\s\\S*)"); //
Matcher m = p.matcher("this is my test string");
if(m.matches())
Log.d("TRACE", "result " + m.group());
我在gskinners RegExr中测试过Pattern,可以在其中正常工作,然后我逃避了我认为正确的术语,但从未给我任何结果。
Matcher.matches()
想要匹配整个字符串。如果要匹配部分字符串,请使用Matcher.find()
。
Pattern p = Pattern.compile("(^|\\S*\\s)\\S*est\\S*($|\\s\\S*)"); //
Matcher m = p.matcher("this is my test string");
if(m.find())
Log.d("TRACE", "result " + m.group());
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句