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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -