I have to remove a particular token from a String variable.
for eg:
If the String variable is like "GUID+456709876790"
I need to remove the "GUID+"
part from the string and only need "456709876790"
.
How can it be done?
I have to remove a particular token from a String variable.
for eg:
If the String variable is like "GUID+456709876790"
I need to remove the "GUID+"
part from the string and only need "456709876790"
.
How can it be done?
If you're using
apache.commons.lang
library you can useStringUtils
just do:this works for me
Two options:
As you're just removing from the start, you can really easily use substring:
To remove it everywhere in the string, just use replace:
Note the use of
String.replace()
in the latter case, rather thanString.replaceAll()
- the latter uses regular expressions, which would affect the meaning of+
.Just try this one :
I am assuming that you want only digits as I have used regex here to remove any thing that is not a digit