Skip to content

Instantly share code, notes, and snippets.

@RyanNutt
Last active January 22, 2018 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanNutt/bad7ab110dc929dde44681fc8050057e to your computer and use it in GitHub Desktop.
Save RyanNutt/bad7ab110dc929dde44681fc8050057e to your computer and use it in GitHub Desktop.
List<String> words = new ArrayList<String>(Arrays.asList(new String[]{"howdy", "there", "neighbor"}));
String trimmed = String.join(", ", words);
System.out.println(trimmed);
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