regex - Check currency field only contains 1 fullstop -
Anyone can help me write a regular expression to check a string in a specific format - 300.00
In this '.' Before and after only numbers can be 'me.' Should only have one presence
so 300.00 or 300.0.0 is invalid.
^ [0 -9] + \. [0-9] * $
This means that the beginning of the string ( ^
), one or more digits ( [0- 9] +
), the optional period ( \.?
), then 0 or more digits, then the end of the string. You can modify it as necessary, e.g. To allow the string to start from the duration (first change ?
).
Comments
Post a Comment