in reply to splitting headache

I'd use a regex like:
print "$_\n" for "'Pugh.Pugh'.Barney.McGrew.Cuthbert.Dibble.Grub"=~/(' +.+?'|".+?"|[^\.]+).?/g
Update: Or maybe
/('(?:[^'\\]*|\\.)+'|"(?:[^"\\]*|\\.)+"|[^\.]+).?/g

Replies are listed 'Best First'.
Re: Re: splitting headache
by Wibble (Beadle) on Feb 26, 2002 at 14:30 UTC
    Thanks a lot for the answer -- this is perfect. The first regex works just fine for me and seems to handle nested "''" and '""' ok too, which is an advantage. You seem like the regex king; the 2nd regex looks very impressive -- erm what does it do?
      The second regex is for escaping quotes with '. Like: 'Blah.Blah\'blah'. I'm not sure about it tho...