|Syntactic Confectionery Delight|
Re: Help on using alternation grouping star versus dot star.by andreychek (Parson)
|on Jun 10, 2001 at 08:01 UTC||Need Help??|
Well, I'll leave the regular expression evaluating to the guru's here.. :-) However, you asked if there are other ways to handle what you are looking to do, so I'll offer two.
There are two modules at CPAN, HTML::Parser and HTML::TokeParser.
HTML::Parser is an event driven HTML code parser. It parses through your document, and calls a function of your choice upon seeing any HTML Start Tag. Whenever it hits an HTML End Tag, it also calls a function of your choice. You could use this method to rewrite your HTML code, by having the functions HTML::Parser calls test to see if the tag is named "div". If so, you can change the name. I'm not sure how it handles attribute tags though.
I personally have had more luck with HTML::TokeParser. It would allow you to write code such as:
Which would find the next div start tag. If it returns something, you can first test it's attributes. If the class attribute equals "blackqte", you could have some code to rewrite the entire tag. HTH!