Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The sort of data that I using is:use strict; use warnings; my $text = "C:\\letters.txt"; my @letters; open(IN, $text) || die "Can't open $text"; @letters = <IN>; close(IN); chomp @letters; foreach my $indiv_note (@letters) { my $letter_text = ($indiv_note =~ /(^\[Sidenote (?: (?!^\[Sidenote). + )* )/); print "<div>$letter_text</div>\n"; }
[Sidenote: The same.] _Sunday Evening._ * * * * * I have at this moment got Pickwick and his friends on the Rochester coach, and they are going on swimmingly, in company with a very different character from any I have yet described, who I flatter mysel +f [Sidenote: Miss Hogarth.] FURNIVAL'S INN, _Wednesday Evening, 1835._ MY DEAREST KATE, The House is up; but I am very sorry to say that I must stay at home. +I have had a visit from the publishers this morning, and the story canno +t
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regexing a block of text in between patterns
by ikegami (Patriarch) on Mar 10, 2009 at 14:36 UTC | |
|
Re: Regexing a block of text in between patterns
by mwah (Hermit) on Mar 10, 2009 at 14:39 UTC | |
by CountZero (Bishop) on Mar 10, 2009 at 17:15 UTC | |
by mwah (Hermit) on Mar 10, 2009 at 18:03 UTC | |
by CountZero (Bishop) on Mar 10, 2009 at 19:42 UTC | |
|
Re: Regexing a block of text in between patterns
by codeacrobat (Chaplain) on Mar 10, 2009 at 16:22 UTC | |
|
Re: Regexing a block of text in between patterns
by kennethk (Abbot) on Mar 10, 2009 at 14:40 UTC |