Reg Ex question.
-
Dear CPians, I am trying to make a regular expression to be used in ASP (VB Script). I need to search for a specific TAG within an HTML file. I want the regullar expression to provide me with the TAG as one MATCH and all its attribute names and value pairs in SUBMATCHES. For example if the following TAG existed in an HTML file, my regular expresion should return the tag as it is. <SPAN id="spanId" onclick="doSomething();">my span</SPAN> and then I would like to get the atribute pairs as such: id spanId onclick dosomething So far I have come up with this pattern: <SPAN\s*(((\w+)=(.*?))*)?>(?:.*?)</SPAN> The pattern above would return the tag as it is in the HTML file. then all the attributes together as such: id="spanId" onclick="doSomething();" and then it will return only the last attribute name-value pair. onclick dosomething discarding the first one (id,spanId) Any ideas? theJazzyBrain
Excellence is not an act, but a habit!
Aristotle