You can try to cast it to number and catch an exception if its not a number
def a= ' 12.571245ERROR'
try {
a as Double
println "a is number"
}catch (e) {
println "a is not a number"
}
Or
if(a instanceof Number)
println "Number"
else
println "NaN"
Although keep in mind, in the second way of checking it, it would fail even if a
is a valid number but in a String
like "123". 123 is Number but "123" is not.