Saturday, 24 August 2013

Split SPECIFIC part of string using regular expression in Ruby

Split SPECIFIC part of string using regular expression in Ruby

I am facing an interesting issue. I want to split string by comma.
"a,s".split ',' => ['a', 's']
But I don't want to split the substring if its wrapped by parentheses, see
example below.
"a,s(d,f),g,h" should yield in ['a', 's', 's(d,f)', 'g', 'h']
any suggestion ?

No comments:

Post a Comment