我想在Java中使用正则表达式提取给定字符串中以下字符之间的字符串:
/*
1) Between \" and \" ===> 12222222222
2) Between :+ and @ ===> 12222222222
3) Between @ and > ===> 192.168.140.1
*/
String remoteUriStr = "\"+12222222222\" <sip:+12222222222@192.168.140.1>";
String regex1 = "\"(.+?)\"";
String regex2 = ":+(.+?)@";
String regex3 = "@(.+?)>";
Pattern p = Pattern.compile(regex1);
Matcher matcher = p.matcher(remoteUri);
if (matcher.matches()) {
title = matcher.group(1);
}
我正在使用上面给出的代码片段,它无法提取我想要的字符串。我做错什么了吗?同时,我对正则表达式很陌生。