Sunday, 13 August 2017

java - removal of double quotes in a sentence



I have a text like this:




“@joemcelderry91: I've woken up with the flu I think! :( gunna try and
run it off haha!! X” get well soon joey :)


I want to get rid of the double quotes in the sentence. After removal it should be like



@joemcelderry91: I've woken up with the flu I think! :( gunna try and
run it off haha!! X get well soon joey :)



Does anybody have suggestions for removing this so far I have tried this still no luck:



.replaceAll("\"", "");

Answer



It seems like you included a different quotes. So Your regex would be,



"[“”\"]"



Replace it with an empty string.



DEMO



OR



If it's a special double quotes then use the below code to remove it from from the string,



String str = "“@joemcelderry91: I've woken up with the flu I think! :( gunna try and run it off haha!! X” get well soon joey :)";
String s = str.replaceAll("[“”]", "");

System.out.println(s);


Output:



@joemcelderry91: I've woken up with the flu I think! :( gunna try and run it off haha!! X get well soon joey :)


IDEONE


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...