in reply to RegEx related line split
You only had two capturing ()'s so $3 won't return anything your way. The .+ captures everything up to (d) since it is greedy.
To make your regex work:
my $RefLine = "(a) This is first line. (b) This is second line; (c) Th +is is different line 32. (d) Here is the last line."; @lines = $RefLine =~ /(\([a-z]\).*?)(?=$|\([a-z]\))/g; print ">>$_<<\n" foreach @lines;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: RegEx related line split
by dominic01 (Sexton) on Nov 14, 2011 at 03:17 UTC | |
Re^2: RegEx related line split
by remiah (Hermit) on Nov 14, 2011 at 08:54 UTC | |
by JavaFan (Canon) on Nov 14, 2011 at 11:41 UTC | |
by remiah (Hermit) on Nov 14, 2011 at 12:40 UTC |
In Section
Seekers of Perl Wisdom