Gary
Gary

Reputation: 13

RegEx ignore in java

Hi i've got a String like "DE32424;WV424324;FR234324;DE45345"

How would I ignore everything after the first ; so only DE32424 would be left in the string after using .replaceAll() in JAVA.

Upvotes: 1

Views: 249

Answers (2)

Carl Smotricz
Carl Smotricz

Reputation: 67820

yourString.substring(0, yourString.indexOf(';'))

Upvotes: 1

Carl Smotricz
Carl Smotricz

Reputation: 67820

replaceAll(";.*", "");

Upvotes: 2

Related Questions