[Israel.pm] How to "split" but keep the delimiter
yuval at windax.com
Mon Dec 6 05:27:44 PST 2004
Yossi.Itzkovich at ecitele.com wrote:
>I know I can do it without "split", but still, by using split, how can I
>still leave the delimiter in the returned list ?
>my @out=split (/instance No \d+/ , $text)
>I want to iterate over @out, but still having that \d in place
Do you want to keep only the \d+ or everything?
Try using a zero-width-positive-lookahead (?=).
my @out = split(/instance No (?=\d+)/, $text);
More information about the Perl