in reply to Re: csv'ish string with parens that include commas
in thread csv'ish string with parens that include commas

m/\G( [^,()]* \( [^()]* \) | [^,()]+ )(?:,|$)/g­x;

Replies are listed 'Best First'.
Re^3: csv'ish string with parens that include commas
by BrowserUk (Patriarch) on Dec 05, 2010 at 07:15 UTC

    Is that intended as an improvement? What purpose does the \G serve?

      #perl -l for( 'sue,fred,x(mary,jane)', 'x(a,b),c(d,e,f),g,h,i(j,k)', 'a,b,cdef(g),h,i(j)', 'a,b,c(d(e,f,g)),h,i(j)' ) { print join' | ', m/( [^,(]+ \( [^)]+ \) | [^,]+ )(?:$|,)/gx; print join' | ', m/( [^,()]+ \( [^()]+ \) | [^,()]+ )(?:$|,)/gx; print join' | ', m/\G( [^,()]* \( [^()]* \) | [^,()]+ )(?:,|$)/gxc +; if( length != pos ) { warn "Invalid input: $_\n"; } print ''; };; ... a | b | c(d(e | f | g)) | h | i(j) a | b | e | f | h | i(j) a | b Invalid input: a,b,c(d(e,f,g)),h,i(j)