Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Apply the suggested mask solution in Clear category for Is String a Number? (Part II) by Tinus_Trotyl
def is_number(val: str) -> bool:
match val[0:1]:
case '+' | '-': val = val[1:] # Remove 1 left '+' or '-' exclusive
val = val.replace('.', '', 1) # and only 1 decimal point.
return all('0' <= c <= '9' for c in val) and bool(val) # By now, there must be only, and at least 1 decimal(s) left.
Dec. 28, 2022
Comments: