RosettaCodeData/Task/Determine-if-a-string-is-numeric/Groovy/determine-if-a-string-is-numeric-1.groovy
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07: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()
}