-2

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";
MR AND
  • 376
  • 7
  • 29
Rachel
  • 1,131
  • 11
  • 26
  • 43

5 Answers5

0

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.

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82
0

You can use String.replaceAll() to accomplish this.

String newValue = value.replaceAll("[']", "");
Makoto
  • 104,088
  • 27
  • 192
  • 230
0

Use this

value.replaceAll("'", "");
Jayamohan
  • 12,734
  • 2
  • 27
  • 41
0

You can use RegEx to remove any special characters or specific characters you want.

Abdullah Shaikh
  • 2,567
  • 6
  • 30
  • 43
0

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

Aniket Inge
  • 25,375
  • 5
  • 50
  • 78