-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
  • 326
  • 5
  • 26
Rachel
  • 1,111
  • 10
  • 25
  • 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,436
  • 3
  • 56
  • 81
0

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

String newValue = value.replaceAll("[']", "");
Makoto
  • 100,191
  • 27
  • 181
  • 221
0

Use this

value.replaceAll("'", "");
Jayamohan
  • 12,469
  • 2
  • 26
  • 40
0

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

Abdullah Shaikh
  • 2,487
  • 6
  • 28
  • 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
  • 24,753
  • 5
  • 47
  • 78