SyntaxFix
Write A Post
Hire A Developer
Questions
Guava's CharMatcher provides a concise solution:
output = CharMatcher.javaLetterOrDigit().retainFrom(input);