in reply to Re: general regex question
in thread general regex question
[id://TedPride]'s code has taken advantage of the fact that all the surnames are between <b> tags. The regular expression matches any text that starts with a general tag (<\w+?>, like "<br>"), is then followed by a bold tag (<B>) and a name starting with "Mac" and one or more following characters ((Mac\w+?)). The parentheses "capture" the matched text to the special variable $1. Updated after [id://Anonymous Monk]'s post below.open ($handle, 'surnames.html'); while (<$handle>) { $hash{$1} = () if m/^<\w+?><B>(Mac\w+?)<\/B>/i; } close ($handle); print '"' . join ("\",\n\"", sort keys %hash) . '"';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: general regex question
by Anonymous Monk on May 15, 2005 at 04:25 UTC |