>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? if you use the replace function, you can assign a function as the replace value for grouped items(i.e. in parens) for example var countDiv=0; var DivIDs =[]; var re = new RegExp("(\<div\s+id=\"?(.+)[\" ](.*?)<\/div>)","i"); myString.replace(re,function(){ DivIDs[countDiv++] = arguments[2]; return arguments[1]; }); I haven't tested this, and I may have my arguments in the wrong place here(and who knows how many other bugs), but I think you might be able to at least get an idea from this. Hope this helps, Chris -----Original Message----- From: Richard Bennett [mailto:[EMAIL PROTECTED]] Sent: Friday, July 20, 2001 4:28 AM To: [EMAIL PROTECTED] Subject: [Dynapi-Dev] reqexp help needed 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 _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/dynapi-dev
RE: [Dynapi-Dev] reqexp help needed
Strolia-Davis Christopher Contr MSG MAM Fri, 20 Jul 2001 06:46:00 -0700
- [Dynapi-Dev] reqexp help needed Richard Bennett
- RE: [Dynapi-Dev] reqexp help ... martin ström
- Re: [Dynapi-Dev] reqexp help ... Michael Pemberton
- Re: [Dynapi-Dev] reqexp help ... Joachim Lundgren
- Strolia-Davis Christopher Contr MSG MAM