简体   繁体   中英

Exclude a portion of a string with regex

I have the string below:

Identification of the product - AZEC

How can I create a regex to exclude Identification of the product - and return only the string that comes next, in this case, AZEC

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

I tried the one below and this seems to work:

(?m)(?<=\\bIdentification of the product - ).*$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM