Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 匹配引号中后跟单词xyz_id的字符_Regex - Fatal编程技术网

Regex 匹配引号中后跟单词xyz_id的字符

Regex 匹配引号中后跟单词xyz_id的字符,regex,Regex,有必要将字符串集匹配到引号中,引号后面紧跟着world“xyz_id”:例如,文本如下:“xyz_id”:“55555”只需要使用正则表达式获取55555。下面的正则表达式将帮助您提取“5555555”: 下面是Java中的示例代码: String x = "\"xyz_id\":\"55555\""; //String on which processing needs to be done Pattern pat1 = Pattern.com

有必要将字符串集匹配到引号中,引号后面紧跟着world
“xyz_id”:
例如,文本如下:
“xyz_id”:“55555”
只需要使用正则表达式获取55555。

下面的正则表达式将帮助您提取“5555555”:

下面是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

你在使用哪种编程语言或工具?你自己有没有尝试过解决这个问题?谢谢@Mukesh这一行专门解决了我的问题:
System.out.println(mat1.group(1))55555