From: dblack@...
Date: 2006-10-25T21:45:39+09:00
Subject: Re: parsing HTML code with regex
Hi --
On Wed, 25 Oct 2006, Michael Perle wrote:
> Anthony Walsh wrote:
>> I'm trying to parse through some html code and count the number of times a
>> match happens. The file is a large table with a ton of
and
> 'something'>. There are no spaces in the file. I'm trying to count and
>> print each
and
.
>>
>> I haven't even gotten to counting my matches. I'm still working on matching
>> with
or
>>
>> I've done:
>>
>> op_file = HTML_CODE
>> if op_file =~ /(
)+/
>
> You are parsing always one line only.
> Perhaps you mean a Regular Expression like
>
> /(
]*?>)+/m
The /m doesn't make any difference there, because you're not using the
wildcard dot. /m just adds \n to the dot class.
David
--
David A. Black | dblack@wobblini.net
Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com | [4] http://www.rubycentral.org