S
stevob
I am trying to make sure a string that I have is in the format xxxxx.xx
(where x are digits only, and there can be any number of digits before
the . but only two after.) I have tried many different regex
combinations and I can't seem to get it to work. Here is what I have
most rescently that I think should work, but doesn't:
$amount=~/^[0-9]+(\.[0-9]{2})$/
Here is my thinking:
^[0-9]+ means that the begining of the string can only contain digits,
but as many as desired.
(\.[0-9]{2})$ means that, must contain a decimal and then only two
digits after that decimal at the end of the string.
Any help is appreciated.
(where x are digits only, and there can be any number of digits before
the . but only two after.) I have tried many different regex
combinations and I can't seem to get it to work. Here is what I have
most rescently that I think should work, but doesn't:
$amount=~/^[0-9]+(\.[0-9]{2})$/
Here is my thinking:
^[0-9]+ means that the begining of the string can only contain digits,
but as many as desired.
(\.[0-9]{2})$ means that, must contain a decimal and then only two
digits after that decimal at the end of the string.
Any help is appreciated.