c# regular expression validate currency, float or integer

美元金额正则表达式

Currency:

^\$?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$

 

C# codes:

float num;
bool isValid = float.TryParse(str,NumberStyles.Currency, CultureInfo.GetCultureInfo("en-US"),out num);
http://www.regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3
posted @ 2009-08-12 18:15  emanlee  阅读(531)  评论(0编辑  收藏  举报