【发布时间】:2019-11-16 16:16:09
【问题描述】:
我知道在这方面有很多类似的主题,我已经尝试了解决方案,但尽管阅读了它们,但我似乎无法解决我的问题 - 请原谅我。
- Regex - Find numbers that do not contain two decimal places
- Regex for whole numbers only and not a blank string
- REGEX for whole, positive number
- What's the regular expression for positive whole numbers only? (zero is not allowed)
- Regex that accepts only numbers (0-9) and NO characters
- Regex to match only numbers in currency
谁能告诉我下面这两个代码有什么问题,以至于它无法满足我只选择整数的标准。 (参考下面两张图)
选项 1 - 如何防止选择 $2000.5,因为它不是整数?
\$\d+[^.|x](?![0-9])
选项 2 - 此代码未选择 $2000.5,但未选择 $100(这是一个整数)。
\$\d+$
数据
5x Item C $2.5x5, $2.50x1
1 Book $2.55
1x Table $2.59
2x Item A $2000.5x2, 10x Item B $0.5x10
1x Test $2.513, 5x Pear $100x5
$1.430
$1.50
$1.55
10x Tee $0.5x10
50x SSS $6.5x50
$2.5, $50
非常感谢。
【问题讨论】: