tags:

views:

50

answers:

3

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.

+2  A: 

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

Carl Smotricz
+1  A: 

Thanks i've got it working with the regexp:

;.*
Gary
+1  A: 

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

Carl Smotricz
Careful. What if `yourString.indexOf(';')` returns `-1`?
Asaph
I believe in the infallibility of the surrounding program as provided by the OP. He says there's a semicolon, of course I believe him :)
Carl Smotricz
This option may be faster than regexp. Worth to try.
Vladimir Dyuzhev