Can anyone please help me to find the suitable regular expression to validate a string that has comma separated numbers, for e.g. '1,2,3' or '111,234234,-09', etc. Anything else should be considered invalid. for e.g. '121as23' or '123-123' is invalid.
I suppose this must be possible in Flex using regular expression but I can not find the correct regular expression.
@Justin, I tried your suggestion /(?=^)(?:[,^]([-+]?(?:\d*\.)?\d+))*$/ but I am facing two issues:
- It will invalidate
'123,12'which should be true. - It won't invalidate
'123,123,aasd'which is invalid.
I tried another regex - [0-9]+(,[0-9]+)* - which works quite well except for one issue: it validates '12,12asd'. I need something that will only allow numbers separated by commas.
[,^]was trying to match a literal^character. I've replaced it with(?:,|^)and it seems to work fine when I test it. Try the edited pattern below. - Justin Morgan