Hi,
I know there's a couple of regexp wizards on the list, I wonder if someone
can help with this:
It's part of an improved inline-layer code I'm working on (thanks to some
ideas from Joshua Hewitt) , where all browsers can get the HTML of the
layer. For NS4 it involves parsing this html out of the body of the
document.
I have this working fine now, but am a bit stuck getting the regexps to
recognize nested <div> tags, what I have so far:
docValue holds the complete html from between the <body> tags:
function getHTML(id,docValue){
var re=new RegExp("(<div id=\""+id+"(.*?)<\/div>)","i");
var arr = re.exec(docValue)
var outer=(arr)?arr[0]:null
var re2=new RegExp(">(.*?)</div>")
var arr2 = re2.exec(outer)
var inner=(arr2)?arr2[1]:null
alert(outer)
alert(inner)
}
currently I'm using two steps, first one gets the outer html for a div tag
with the passed id, second one gets whatever is between ">" and "</div>" -
the inner html.
The problem arises when the div contains child divs, is there someway to
count the amount of "<div" tags, and continue the search until an equal
amount +1 of "</div>" tags have been matched?
Richard.
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev