• Post Reply Bookmark Topic Watch Topic
  • New Topic

seek regular expression  RSS feed

 
Hui Zhao
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I have a string which may contain any character.
I want to remove single quotes or double quotes in it.
For ex.
I want to get

how to?
Thanks
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To remove them, you can use String.replaceAll.

For this, the regular expression is '|" (single quote or double quote). In Java, this makes s.replaceAll("'|\"", "");

This will not get you your desired string though, since there will be no space between Hello and world.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!