p4l / isinteger
public text v1 · immutable###btw i didnt code this. found it today :)
# Returns 1 if v is an well-formed integer,
# and 0 otherwise. Does not work for floats.
#
proc isinteger {v} {
return [regexp {^[+-]?[0-9]+$} $v]
}
# Returns 1 if v is an well-formed float,
# and 0 otherwise. Works also for floats with
# mantisse and exponent... and of course for integers.
#
proc isfloat {v} {
return [regexp {^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.[0-9]*)|([0-9]+))((e|E)[+-]?[0-9]+)?$} $v]
}