Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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
正则表达式从Java中的字符串下面提取/分组冒号后面的所有值_Java_Regex - Fatal编程技术网

正则表达式从Java中的字符串下面提取/分组冒号后面的所有值

正则表达式从Java中的字符串下面提取/分组冒号后面的所有值,java,regex,Java,Regex,我有一根这样的线: 1454974419:1234;1454974448:3255,2255,66789 1454974419:1234;1454974448:3255,2255,66789 我想在java中使用正则表达式来提取/分组这些值 1234 1234 3255225566789您可以使用这个基于查找和否定的正则表达式: (?<=[:,])[^;,]+ (?试试这个 String yourString= "1454974419:1234;1454974448:3255,2255,

我有一根这样的线:

1454974419:1234;1454974448:3255,2255,66789 1454974419:1234;1454974448:3255,2255,66789 我想在java中使用正则表达式来提取/分组这些值

1234 1234
3255225566789

您可以使用这个基于查找和否定的正则表达式:

(?<=[:,])[^;,]+
(?试试这个

String yourString= "1454974419:1234;1454974448:3255,2255,66789";
          Pattern myPattern = Pattern.compile("[^a-zA-Z0-9]");
          Matcher myMatcher = myPattern.matcher(yourString);
            while(myMatcher.find())
            {
                String temp= myMatcher.group();
                yourString=yourString.replaceAll("\\"+temp, "");
            }
System.out.println(yourString);

请展示你到目前为止的成果。太好了,非常有魅力。谢谢。必须用()包围,然后才能按模式提取。编译((?)对不起,这不是我想要的。请尝试在接受的答案中使用正则表达式。我给出这个答案,因为模式和匹配器来自正则表达式库。 66789
(?<=[:,])[^;,]+
(?<=[:,])  # lookbehind to assert if previous char is : or ,
[^;,]+     # match 1 or more of anything that is not a ; or ,
String yourString= "1454974419:1234;1454974448:3255,2255,66789";
          Pattern myPattern = Pattern.compile("[^a-zA-Z0-9]");
          Matcher myMatcher = myPattern.matcher(yourString);
            while(myMatcher.find())
            {
                String temp= myMatcher.group();
                yourString=yourString.replaceAll("\\"+temp, "");
            }
System.out.println(yourString);