It's not a secret anymore!*
The moose likes Java in General and the fly likes After adding  the regular expression it is removing the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

After adding the regular expression it is removing the "f" and "," character.

Shaik Riyaz
Greenhorn

Joined: Apr 17, 2008
Posts: 7
Whenever I am trying to replace all the character rather than ASCII and some characters which are including in ASCII it is removing only letter "f" and comma character from the variable.Can anyone let me know why this is happening?Please find my code as below:

public static String formatString() {
String st="!@#$%^&*abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.";
String temp = Normalizer.normalize(st, Normalizer.DECOMP, 0);
String string1=temp.replaceAll("[^\\p{ASCII}]","");
String string2=string1.replaceAll("[\\x01-\\x08,\\x0b-\\x0c,\\x0e-\x1f,\\x7f-\\xffff]", "");
return string2;

}
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Please do not post the same topic in more than one forum.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: After adding the regular expression it is removing the "f" and "," character.
 
Similar Threads
what is difference between String[] string1 and String string2[]
Regular expression
String Comparison(s)
equals()
New Line Character Marshalling issue