need a regex for a positive max 2 digits after . floating number
Hi I need a C# regex fo开发者_运维问答r a positive floatin no with maximum 2 digits for decimals. Also the regex should check for letters and alphanumerical chars (not allow them) and not allow also the input value to be empty (0 characters). Thanks
^[+]?[0-9]+([.][0-9]{1,2})?$
This will force it to have either a +
or nothing at the start, followed by at least 1 number, then optional (decimal followed by 1 or 2 numbers)
For others, yes, I know of \d
, :digit:
, using \.
, etc. I just prefer using [0-9] and [.], it makes them stand out easier for me.
精彩评论