RosettaCodeData/Task/Determine-if-a-string-is-numeric/Groovy/determine-if-a-string-is-numeric-1.groovy
2023-07-01 13:44:08 -04:00

9 lines
273 B
Groovy

def isNumeric = {
def formatter = java.text.NumberFormat.instance
def pos = [0] as java.text.ParsePosition
formatter.parse(it, pos)
// if parse position index has moved to end of string
// them the whole string was numeric
pos.index == it.size()
}