My pages in my website contains elements with formatting elements hard coded onto them, instead of having all the formatting set through a class reference to a stylesheet. This means that I will have an element with it's bgcolor attribute set to "blue" and it's border attribute set to "1". For example: <p bgcolor="blue" color="red" border="1">bla di bla bla</p> I want to set a class name attribute on all the elements, with a combination of these two attributes with the same values. Meaning any element having a bgcolor of "blue" and a border of "1". The following will qualify too: <td bgcolor=blue id="mytd" onclick="alert('clicked');" border="1">Hello</td> So how can I find all the instances of tags that have these two attributes with the correct values in the markup? A normal string operation will not suffice. So a regular expression solution is sufficient. But when the border and bgcolor sequence is switched it adds a whole new level of complexity to the regular expression, for example: <td border="1" id="mytd" onclick="alert('clicked');" bgcolor=blue>Hello</td>Now we can't assume that the bgcolor attribute will be found first and then the border attribute. And what about when we want to search on three attributes?
Now we can't assume that the bgcolor attribute will be found first and then the border attribute. And what about when we want to search on three attributes?
|