C# RegEx for decimal number
问题 I'm trying to make a Regular expression for a textbox which should only allow either only digits or decimals. For example, I should be able to enter both 10 and 10,350. The decimal seperator I'll use is "," and the decimal length don't need a limit. Anyone knows how I can make such a RegEx? 回答1: I'd go for decimal.TryParse() too, but if you really need a RegEx then something like this should work: (\d+(,\d*)?) 回答2: Just use decimal.TryParse or double.TryParse . 回答3: if you will use it in many