Skip to content

Instantly share code, notes, and snippets.

@relax-more
Created October 30, 2012 03:31
Show Gist options
  • Save relax-more/3978152 to your computer and use it in GitHub Desktop.
Save relax-more/3978152 to your computer and use it in GitHub Desktop.
[Java] String文字列の前後から空白・改行文字を取り除く
public static String trim(String string) {
return string.replaceAll("^[\\s ]*", "").replaceAll("[\\s ]*$", "");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment