[英]Request For Java Regex String
i was wondering if anybody could help me with a RegEx i need to use for matching strings in the format "4%,6%,8%,9%" "(Number)(Percentage)(comma)(number)(percentage)....N"
我想知道是否有人可以使用RegEx来帮助我匹配
"4%,6%,8%,9%" "(Number)(Percentage)(comma)(number)(percentage)....N"
格式的字符串"4%,6%,8%,9%" "(Number)(Percentage)(comma)(number)(percentage)....N"
I tried hard to get this one ^[\\d*(?:%),]+$
but its matching the format "4%,2,6,5%"
(numbers without percentage simbol). 我尽力获得一个
^[\\d*(?:%),]+$
但其格式与"4%,2,6,5%"
(不包含simbol的数字)相匹配。
Thanks in advance! 提前致谢!
Change your regex like below, 如下更改您的正则表达式,
^\d+%(?:,\d+%)+$
(?:,\\d+%)+
Allows one or more strings of this ,<number>%
format. (?:,\\d+%)+
允许一个或多个此,<number>%
格式的字符串。
OR 要么
^\d+%(?:,\d+%)*$
(?:,\\d+%)*
Allows zero or more strings of this ,<number>%
format. (?:,\\d+%)*
允许零个或多个此,<number>%
格式的字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.