RE: pattern matching problem
by Joseph Discenza other posts by this author
Jul 30 2004 3:51PM messages near this date
view in the new Beta List Site
PDF to text
|
RE: Perl threads crash perl
Craig Cardimon wrote, on Friday, July 30, 2004 11:36 AM
: To: activeperl@listserv.ActiveState.com;
: perl-win32-users@[...].com
: Subject: pattern matching problem
:
:
: I am searching text files for the keyword Exhibit or Form followed by a
: number, a decimal, and any number of letter or numbers within
: parentheses or not.
:
: For example:
:
: Exhibit 12
: Exhibit 12.1
: Exhibit 12(a)
: Exhibit 12.1(a)
: Exhibit 12.1(2)
: Exhibit 12.1(a)(b)
: Exhibit 12.1(1)(2)
: Exhibit 12 (a)
: Exhibit 12.1 (a)
: Exhibit 12.1 (2)
: Exhibit 12.1 (a) (b)
: Exhibit 12.1 (1) (2)
:
: Examples of what I would NOT want:
:
: "Exhibit 3.11(1) - Articles of Incorporation of The Lehigh Press, Inc."
:
: I use this:
:
: if( ($textarea_line =~ m/^\s*(Exhibit\s+[\d.]+)(\s*\([^\s]*)?.*$/i) &&
: ($textarea_line !~ m/[\w+]$/i) )
:
: The problem is, this works inconsistently.
:
: These are two lines that should not be found:
:
: "Exhibit 4.4(1) - Registration Rights Agreement, dated October 22, 2003
: among Von"
:
: "Exhibit 3.11(1) - Articles of Incorporation of The Lehigh Press, Inc."
:
: The first line is screened out. That's fine.
:
: The second line, however, gets through. The search extracts the "Exhibit
: 3.11(1)" part.
:
: Any clues as to why?
Because it ends with "." (after the "Inc"), which is not a \w character.
Also, it looks like you don't have an escaped right parenthesis to
balance the escaped left parenthesis at the end there.
Try:
if ($textarea_line =~ m/^\s*Exhibit\s+[\d.]+(\s*\([0-9a-zA-Z]+\))*\s*$/i)
(not tested). You also might consider using the /x option so you can
comment your regex and see all the "pieces" separately.
Good luck,
Joe
==============================================================
Joseph P. Discenza, Sr. Programmer/Analyst
mailto:jdiscenza@[...].com
Carleton Inc. http://www.carletoninc.com
574.243.6040 ext. 300 fax: 574.243.6060
Providing Financial Solutions and Compliance for over 30 Years
***** Please note that our Area Code has changed to 574! *****
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Craig Cardimon
Joseph Discenza
|