ToonMariner
08-22-2006, 08:47 AM
Hello all...
I need to perform a regular expression string replacement.
I have this :
str = str.replace('/<div class="imgcont" id="x'+id+'">(.)*<\/div>/i','');
But obviously its not working...
the initial str is the entire contents of a div and that looks like:
<div id="cont">
<div class="imgcont" id="x1">
// all manner of content in here...
</div>
<div class="imgcont" id="x2">
// all manner of content in here...
</div>
</div>
Now as there is all manner of content I can easily see why I may have to use something like..
str = str.replace('/<div class="imgcont" id="x'+id+'">(.)*<div class="imgcont">/i','');
but I suspect the issue here is the new lines in the str.
I don't want the regex to be greedy - not sure if js regex's are or not but any tips would be greatly appreciated..
thanks.
I need to perform a regular expression string replacement.
I have this :
str = str.replace('/<div class="imgcont" id="x'+id+'">(.)*<\/div>/i','');
But obviously its not working...
the initial str is the entire contents of a div and that looks like:
<div id="cont">
<div class="imgcont" id="x1">
// all manner of content in here...
</div>
<div class="imgcont" id="x2">
// all manner of content in here...
</div>
</div>
Now as there is all manner of content I can easily see why I may have to use something like..
str = str.replace('/<div class="imgcont" id="x'+id+'">(.)*<div class="imgcont">/i','');
but I suspect the issue here is the new lines in the str.
I don't want the regex to be greedy - not sure if js regex's are or not but any tips would be greatly appreciated..
thanks.