I want to remove all special characters from the string object below with some characters except for _(underscore) between two words in java ?
my sample data would be
a = *OIL~
b = OIL_GAS_
c = *OIL_GAS$
b = OIL_GAS
This is the output I'm expecting:
OIL
OIL_GAS
OIL_GAS
OIL_GAS
I already have this String str1= s.replaceAll("(\\W)*", "");
And I could remove all special characters. If any one could help me update my code How to remove all special characters except for underscore between two words
Any help would be great thanks.
