class der{
public static void maxLength(String str) {
String s = " ";
s = str.replaceAll("[^a-z]+", " ");
String rev = " ";
char ch[] = s.toCharArray();
for(int i =ch.length-1; i>=0 ; i--){
rev = rev + ch[i];
}
System.out.println(rev);
}
public static void main(String[] args){
String str = "a@utom!at$ion@";
maxLength(str);
}
}
I tried the above with regex function where i first tried to remove special character and then reverse the string. But is there any option to add special character back again to the reverse strings?
My o/p for the current code is this noi ta motu a so in blank space i want to put the special character again.