Last active
August 29, 2015 14:05
-
-
Save acatejr/3c0afe17d78610059366 to your computer and use it in GitHub Desktop.
Groovy string cleanup.
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
/** | |
* Clean spaces and extraneous characters from a text string. | |
* | |
* @params source The source string. | |
* | |
* @return The cleaned version of the input string. | |
* | |
*/ | |
static def cleanString(String source) { | |
if ( source && source.length() > 0 ) { | |
def wordList = source.split("\\s+") | |
[",", ""].each() { i -> | |
wordList -= i | |
} | |
wordList.join(" ") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment