What regex would match any ASCII character in java?
I\'ve already tried:
^[\\\\p{ASCII}]*$
but found that it didn\'t match lots of
I think question about getting ASCII characters from a raw string which has both ASCII and special characters...
public String getOnlyASCII(String raw) {
Pattern asciiPattern = Pattern.compile("\\p{ASCII}*$");
Matcher matcher = asciiPattern.matcher(raw);
String asciiString = null;
if (matcher.find()) {
asciiString = matcher.group();
}
return asciiString;
}
The above program will remove the non ascii string and return the string. Thanks to @Oleg Pavliv for pattern.
For ex:
raw = ��+919986774157
asciiString = +919986774157