How to Parse string which contain special character like
I ][][came][][][I][][][][Saw][][][][][][I][][][][Won][][]开发者_如何学编程[][
Can anyone please solve it
Perhaps you're after something like this:
String str = "I ][][came][][][I][][][][Saw][][][][][][I][][][][Won][][][][";
str = str.replaceAll("[^\\p{Alnum}]+", " "); // keep alpha-numeric characters.
System.out.println(str);
prints:
I came I Saw I Won
Check for ascii values of alphabets and space alone.
Figure out the unicode codes of your special characters and use these codes to parse the string:
String specialChar = "\u00f1";
String specialString = "En Espa\u00f1ol";
specialString.split(specialChar);
This is the same as the answer above. But different pattern for regex.
String str = "I ][][came][][][I][][][][Saw][][][][][][I][][][][Won][][][][";
//Search for numeric and alpha characters.
str = str.replaceAll("[^0-9A-Za-z]+", " ");
System.out.println(str);
+1 for the first answer
cheers!
精彩评论