Deepak Kumar Deepak Kumar - 4 months ago 9
jQuery Question

Regex pattern which accept only one char or a number group (decimal also)

I need to write a regex pattern which allow the user to enter a single character (A or a) or numbers

ex:- A or 94.50

Answer

Try

^([A-Z]|([1-9]\d*|0)([.,]\d+)?)$

which also avoids matching multiple leading zeros like 00.445

See the regex101