Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Pattern matching [newbie]
February 13, 2013, 12:16 am
rate this thread
<a href="/question?id=15422849"><p>MY text here 1</p><p>MY text here 2</p><p>MY
text here 3</p></a>
I am doing something like:
$string =~ m/(.*)href(.*)/;
But this is not helping me in what I want. I want something closer to following
"MY text here 1 MY text here 2 MY text here 3"
Can some give some ideas ?
Re: Pattern matching [newbie]
I appreciate that you call yourself a newbie, and to you what I'm about
to suggest may seem complicated and difficult; but that's the way we all
Have you thought of parsing the HTML properly, using a module like
HTML::Tree or HTML::TreeBuilder? The hardest part is choosing the
module; after that you should find it moderately easy to use it do what
you want, since it's pretty simple. And once you've done it it will
probably be a lot better than hand-cranked parsing code.
Note to all concerned: I'm not joining in the "you can't parse HTML with
regexes" thread. In this case, at least, I'm sure that's perfectly
possible. I'm suggesting a way by which a wise newbie can get the job
done and learn something forbye.
Henry Law Manchester, England
- » Parsing Process Log files - looking for Perl Modules
- — Previous thread in » PERL Discussions