How to remove special characters in the string except \"- _\". Now I use:
replaceAll(\"[^\\\\w\\\\s]\", \"\")
it remove all special charact
barely 6 years have passed and we have a lambda solution
String str = "owl@134_- abc";
str.codePoints().mapToObj( Character::toChars ).filter(
a -> (a.length == 1 && (Character.isLetterOrDigit( a[0] ) || a[0] == '-' || a[0] == '_')) )
.collect( StringBuilder::new, StringBuilder::append, StringBuilder::append ).toString(); // owl134_-abc