Pupillam
Pupillam

Reputation: 641

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

Upvotes: 0

Views: 38

Answers (2)

Pupillam
Pupillam

Reputation: 641

I tried the one below and this seems to work:

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

Upvotes: 0

Nir Alfasi
Nir Alfasi

Reputation: 53525

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

Upvotes: 2

Related Questions