Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a file that looks like this:
__FRANK LICHTENBERG, Columbia University _[4]Pharmaceutical Knowledge-Capital Accumulation and Longevity_ BARBARA FRAUMENI and SUMIYE OKUBO, Bureau of Economic Analysis _[5]R&D in the National Income and Product Accounts: A First Look at its impact on GDP_
and I want to grab out the titles. The titles begin with the 4 or 5 and end with a "_" char. In this example, I want to grab out
Pharmaceutical Knowledge-Capital Accumulation and Longevity
and
R&D in the National Income and Product Accounts: A First Look at its impact on GDP
This only matches the 1-liner number 4:
my (@tmp, @titles); while (<IN>) { if ( my @tmp = m/\_[\d\](.+)_/g ) { push @titles, @tmp; } }
How can I write a reg-exp to match across newlines in some but not all instances? I want to get both titles in to my @titles array.
thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to reg-exp match across multiple lines?
by japhy (Canon) on Jul 08, 2002 at 20:27 UTC | |
|
Re: how to reg-exp match across multiple lines?
by joealba (Hermit) on Jul 08, 2002 at 21:00 UTC | |
by Aristotle (Chancellor) on Jul 09, 2002 at 01:42 UTC | |
by Abigail-II (Bishop) on Jul 09, 2002 at 09:24 UTC | |
|
Re: how to reg-exp match across multiple lines?
by TexasTess (Beadle) on Jul 08, 2002 at 23:18 UTC |