Hello all,
This may be a stupid question, but I will really apprecite it if someone can help me with this.
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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.