I have a java String variable with the below value... i want to remove the special characters from it.. how to remove the single upper quotes... how to get this..
String value = "work'list'Man'ager";
I have a java String variable with the below value... i want to remove the special characters from it.. how to remove the single upper quotes... how to get this..
String value = "work'list'Man'ager";
If you look at the String documentation:
http://docs.oracle.com/javase/6/docs/api/java/lang/String.html
You'll note there are multiple methods starting with replace
. I recommend using one of those, as appropriate.
You can use String.replaceAll()
to accomplish this.
String newValue = value.replaceAll("[']", "");
You can use RegEx to remove any special characters or specific characters you want.
A simple example:
public class Main{
public static void main(String[] args){
String s = "work'list'Man'ager" ;
String[] arr = s.split("'");
StringBuilder sb=new StringBuilder();
for(String st: arr)
sb.append(st);
System.out.println(sb.toString());
}
}
and related IDEONE program: http://ideone.com/NarYIC