in reply to Money Regex
Forget about doing gas prices with a regex like this, though (e.g. 1.499). Don't forget about negative-signs also, if that's necessary./^\d+$/ # integer /^\d+(?:\.\d+)?$/ # integer or optional real /^\d+(?:\.\d\d)?$/ # int or opt. 2-digit float /^\d+(?:\.(?:\d\d)?)?$/ # int, int with opt '.', or 2-digit float # Ways of doing optional integer portion (e.g. .12) /^\d*(?:\.(?:\d\d)?)?$/ # WRONG (matches "") /^\d+(?:\.(?:\d\d)?)?$|^\.\d\d$/ # better, but still ugly
I also haven't tested any of that.
|
|---|