in reply to multi-line regexp
This uses a minimum capture .*? and positive look ahead (?=...) with a conditional match aaaaa|$ to do the job:
#! /usr/bin/perl use strict; use warnings; my $str = "aaaaa\nbbbbb\nccccc\naaaaa\nddddd\neeeee\n" ; my @a = $str =~ /(aaaaa.*?)(?=aaaaa|$)/gs ; print join "\n", @a;
Prints:
aaaaa bbbbb ccccc aaaaa ddddd eeeee
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: multi-line regexp
by doctor_moron (Scribe) on Dec 21, 2005 at 20:41 UTC | |
by GrandFather (Saint) on Dec 21, 2005 at 21:07 UTC | |
by Anonymous Monk on Dec 21, 2005 at 22:26 UTC |