> >"Eurospace Szarindar" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] > >Thanks you, it works fine. Could you explain me why have you added the \1 ?
Hi, A quick breakdown... /(['"])(((''|"")|[^'"])*?)\1(\s|$)/g ^^^^^^ 1 ^^^^^^^^^^^^^^^^ 2 ^^ 3 1) This is picking up either a single or double quote 2) This is scoping up any quotes pairs, and is being carefull not to match quotes on thier own. 3) In a regex \1, \2 etc.. will match the same sequence of characters matched earlier in the same-numbered pair of parentheses, in this case, it means that were making sure the opening and closing quotes are the same by mathching that same character as in part 1. Explaining it like this has made me spot a problem. The regex you really want is m/(['"])(((''|"")|[^\1])*?)\1(\s|$)/g This way our 'scoping up' part matches any paired quotes or anything other than our closing quote. The following test data wouldn't have worked... ' data11 '' dat"a12' 'data13' > >I will have a look at Text::CSV > Please do, my mistake above shows you why you shouldn't reinvent this stuff if you can get away with it. :-) Ta Rob > >Michel > >-----Message d'origine----- >De: Rob Anderson [mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]