I am given a string that can include both text and numeric data:
Examples:
"100 pounds" "I think 173 lbs" "73 lbs."
I am looking for a clean way to extract only the numeric data from these strings.
Here is what I'm currently doing to strip the response:
def stripResponse(String response) {
if(response) {
def toRemove = ["lbs.", "lbs", "pounds.", "pounds", " "]
def toMod = response
for(remove in toRemove) {
toMod = toMod?.replaceAll(remove, "")
}
return toMod
}
}