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,我有下面的字符串: 产品标识-AZEC String str = "Identification of the product - AZEC"; System.out.println(str.split(" - ")[1]); // AZEC 如何创建一个正则表达式来排除产品的标识-并只返回下一个字符串,在本例中,AZEC我尝试了下面的一个,这似乎有效: String str = "Identification of the product - AZEC"; System.out.printl

我有下面的字符串:

产品标识-AZEC

String str = "Identification of the product - AZEC";
System.out.println(str.split(" - ")[1]); // AZEC

如何创建一个正则表达式来排除产品的标识-并只返回下一个字符串,在本例中,AZEC我尝试了下面的一个,这似乎有效:

String str = "Identification of the product - AZEC";
System.out.println(str.split(" - ")[1]); // AZEC

(?m)(?您使用的是什么语言?我正在使用Java执行此任务,然后添加语言标记。我尝试\-(*),但它也会返回-及其后面的空格