Created
March 2, 2017 16:03
-
-
Save hperantunes/9634dc7bf23f4283d2deda679274de8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Newlines, tabs and non-printable unicode characters | |
private static final String sanitizePattern = "(\\r|\\n|\\t|\\p{C})"; | |
private static final String whitespacePattern = " +"; | |
private static final String replacementString = " "; | |
private static String sanitize(String text) { | |
return text.replaceAll(sanitizePattern, replacementString); | |
} | |
private static String normalizeWhitespace(String text) { | |
return text.replaceAll(whitespacePattern, replacementString); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment