什么是C#普通EX pression那将验证货币浮动或整数? [英] What's a C# regular expression that'll validate currency, float or integer?

查看:128
本文介绍了什么是C#普通EX pression那将验证货币浮动或整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是正恩$ P $适用于C#pssion如果匹配下面那将验证数字?


  $ 1,000,000.150
 $ 10000000.199
 $ 10000
 1,000,000.150
 100000.123
 10000


或者否定形式?


解决方案

您可以使用csmba的正则表达式,如果你做一个轻微修改它。

  ^ \\ $?(\\ d {1,3},?(\\ d {3},?)* \\ d {3}(\\ D {0,3} )|?\\ d {1,3}(\\ d {2}))$?

What is a regular expression suitable for C# that'll validate a number if it matches the following?

 $1,000,000.150
 $10000000.199
 $10000 
 1,000,000.150
 100000.123
 10000

Or the negative equivalents?

解决方案

You can use csmba's regex if you make one slight modification to it.

^\$?(\d{1,3},?(\d{3},?)*\d{3}(.\d{0,3})?|\d{1,3}(.\d{2})?)$

这篇关于什么是C#普通EX pression那将验证货币浮动或整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆