in reply to splitting headache

Well I played with it for a while and this is the closest I could get. Personally I would recommend that you split on the '.' and then iterate over the current list keeping a track of what you have seen already.
print "$_\n" foreach (split(m/\G(([^\.]+)\.\2)|(?:(?!\2\.)\.)/g, "Pugh +.Pugh.Barney.McGrew.Cuthbert.Dibble.Grub"));
There's probably some stuff in there I don't need but I'm not a regex master by any means :)

Replies are listed 'Best First'.
Re: Re: splitting headache
by Wibble (Beadle) on Feb 26, 2002 at 14:36 UTC
    Thanks for the reply. I guess I should have explained that my "Pugh.Pugh.Barney.McGrew.Cuthbert.Dibble.Grub" string was just an example of a typical string that might occur. The 'word.groupings' could actually come anywhere, not just at the start, so this method won't work for me. Thanks again though.