regex - Java regular expression bug -
i have following regular expression:
^(min|max|sum|average):[(\\d+(\\.\\d+)?), ]+$
the rule attempting implement should allow strings of following format:
operation: (comma separated list of integers or real numbers)
for example following must allowed:
min: 7, 89.7, 67 average: 67.9, 89, 9
however, accepts input of form
max: ,
how can avoid having blank spaces on either side of comma accepted?
try
"^(min|max|sum|average)\\s?:\\s?(\\d+(\\.\\d+)?)(,\\s?\\d+(\\.\\d+)?)*$"
tests:
min:4: true min:4,4: true min:4, 5: true min:4 , 5: false min: 7, 89.7, 67: true average: 67.9, 89, 9: true max: , : false
Comments
Post a Comment