|go ahead... be a heretic|
Re: A regex questionby roboticus (Chancellor)
|on Oct 28, 2011 at 20:22 UTC||Need Help??|
Here's a quick bit of code to get you started:
Note that we slurp all the file in at once ($/=undef) otherwise we can't find names spread over two lines (like Mary Jones). We also need to use the 's' switch on the regular expression to let '.' match newlines (again to pick up Mary Jones!.
Running it gives you:
Now, having said all that: Remember to review perlre and perlop. Also, you may want to use a real HTML parser instead of hacking away with regular expressions. Otherwise you can find some difficulties with unexpected formatting.
When your only tool is a hammer, all problems look like your thumb.
Update: changed 'e' to 's' (thanks for catching that, hbm!)