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

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

  • Comment on Re^3: csv'ish string with parens that include commas

Replies are listed 'Best First'.
Re^4: csv'ish string with parens that include commas
by Anonymous Monk on Dec 06, 2010 at 00:17 UTC
    #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)