coltman has asked for the wisdom of the Perl Monks concerning the following question:
I have a text file which part of it is displayed below. Example RENTAL NOTICE LETTER EXHIBIT 10.2 FIRST RESTATED AND AMENDED AUTO LEASE NOTICE TH +IS LEASE is made as of the 1st day of March, 2001, by and between HAN +NAH RENTAL, CO. a Maine Corporation having its principal offices in P +ortland End What I want is to extract any phrase that contains the word "NOTICE". +In this example, both "RENTAL NOTICE LETTER" and "AUTO LEASE NOTICE" +are the information that I need. Because there can be two ways for locating the phrase "XXX NOTICE YYY" +: (1) (boundary or begining of line) XXX NOTICE YYY (\n); (2) (more than two spaces, such as " ") XXX NOTICE YYY (more than tw +o spaces, such as " " ); I tried with the following: if ($a =~ /(?:\b| +?)(.+)*(NOTICE)(.+)*(?:\n| +?)/i) { print $1." ".$2." ".$3."\n"; }
But it does not work quite well. Can you make some suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to parse this information out?
by Anno (Deacon) on Mar 21, 2007 at 21:12 UTC | |
|
Re: How to parse this information out?
by kyle (Abbot) on Mar 21, 2007 at 18:38 UTC | |
|
Re: How to parse this information out?
by Sixtease (Friar) on Mar 21, 2007 at 21:18 UTC | |
by kyle (Abbot) on Mar 21, 2007 at 21:28 UTC |