有必要将字符串集与引号引起来,然后由引号"xyz_id":
进行匹配,例如,文本如下:"xyz_id":"55555"
仅需要使用正则表达式获得55555。 / p>
答案 0 :(得分:1)
遵循正则表达式将帮助您提取“ 55555”:
\"xyz_id\":\"(.*)\"
https://regex101.com/r/5VnGKN/1
下面是Java中的示例代码:
String x = "\"xyz_id\":\"55555\""; //String on which processing needs to be done
Pattern pat1 = Pattern.compile("\"xyz_id\":\"(.*)\""); //Pattern to compare
Matcher mat1 = pat1.matcher(x);
while(mat1.find()){
System.out.println(mat1.group(1));
}
输出:
55555