Last active
January 22, 2018 20:08
-
-
Save RyanNutt/bad7ab110dc929dde44681fc8050057e 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
List<String> words = new ArrayList<String>(Arrays.asList(new String[]{"howdy", "there", "neighbor"})); | |
String trimmed = String.join(", ", words); | |
System.out.println(trimmed); |
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
String regex = "\\s*,*\\s*$"; | |
String toTrim = "1, 2, 3, 4, 5, "; | |
String trimmed = toTrim.replaceAll( regex, "" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment