This snippet will show how to strip spaces from a string using a regex.
@Test public void strip_spaces() { String sampleString = "Remove space whitespace"; String removeSpaces = sampleString.replaceAll("\s", ""); assertEquals("Removespacewhitespace", removeSpaces); }