Can somebody please show me how to do a Java regex that takes in a string and returns a string with all characters removed BUT a-z and 0-9?
I.e. given a string a%4aj231*9.+ it will return a4aj2319
thanks.
\d is digit, \p{L} is a-z and A-Z.
str.replaceAll("[^\\d\\p{L}]", "");
If you want a-z and 0-9 but not A-Z then
str.replaceAll("[^\\p{Lower}\\p{Digit}]", "");