in reply to help: 'Complex' split
No error checking here. If you wanted error checking, inch along until pos() is at the end of the string, or take the error if it's not and there's no match. Something like:my @pieces = m/\G(<[^>]*>|#[^#]*#|[^#<]+)/g;
It would be nice if list-context m//gc left pos at the last match, but last I checked it was still broken.pos = 0; while (m/\G(<[^>]*>|#[^#]*#|[^#<]+)/gc) { push @pieces, $1; } die unless pos >= length;
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: help: 'Complex' split
by vladb (Vicar) on Dec 26, 2001 at 22:07 UTC |