简体   繁体   English

金额值正则表达式

[英]Amount value regular expression

I am trying to create a regular expression for a dollar amount that accepts values between 5.00 and 1000.00. 我试图为美元金额创建一个接受5.00到1000.00之间的值的正则表达式。

Here is what I have so far: 这是我到目前为止的内容:

^([5-9](\d){0,4}([.](\d){1,2})?|1000([.](0){1,2})?)?$

I have already tried the range validator and it isn't working this field. 我已经尝试过范围验证器,但该字段不起作用。

Any help is much appreciated. 任何帮助深表感谢。

This is what I came up with, which could likely be improved. 这是我想出的,可能会得到改善。 It seems to work for my limited testing. 它似乎适用于我的有限测试。 You may want to tag your question with "regex" to get some expert advice! 您可能想用“ regex”标记您的问题,以获得一些专家建议!

^(?:[5-9](?:\.\d{0,2})?|\d{2,3}(?:\.\d{0,2})?|1000(?:\.0{0,2})?)$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM