http://www.perlmonks.org?node_id=1214539


in reply to Re^2: check if string is valid with special cases
in thread check if string is valid with special cases

the substring can conatin commas in it

Sorry, this doesn't make sense to me. If the input string is "1,2,3,4,5,6,7", then does $a get "1,2", or does $b get "2,3", and so on...

Or is this CSV, as swl correctly pointed out? Then you should use Text::CSV.

If not, then as I said, please provide lots of examples of valid input with the expected output, as well as lots of examples of invalid input.