probably a silly question. I'm trying to find and replace the following code in javascript. So that code is part of an ajax response with a lot of html code. So, I'm getting the ajax response, and I put it on a string variable, and using replace() I'm trying to remove the following tags combination. Any idea will be appreciated?
<ul>
</li>
</ul>
Javascript replace uses RegEx
(regular expressions)...
the pattern for your (invalid) tag-combination to remove will be:
result = subject.replace(/<ul>[\t\r\n ]*<\/li>[\t\r\n ]*<\/ul>/ig, "");
this replaces all <ul>
's, followed by an </li>
, followed by an </ul>
with only "newline, carriage-return, tabulator or space" between them.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments