Skip to content

Instantly share code, notes, and snippets.

@Marcelektro
Created December 6, 2020 20:58
Show Gist options
  • Save Marcelektro/270587e2a887d4ac70f505c1f67f2565 to your computer and use it in GitHub Desktop.
Save Marcelektro/270587e2a887d4ac70f505c1f67f2565 to your computer and use it in GitHub Desktop.
spaceTrimmer
package net.marcelektro;
public class Main {
public static void main(String[] args) {
String pog = "HELLO THERE ARE WAYYYYY TOOO MANY SPACES RIP OOF SAD";
System.out.println(trimSpaces(pog));
}
public static String trimSpaces(String textToTrim) {
return textToTrim.trim().replaceAll(" +", " ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment