Replace multiline string with js

srecce

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>
TheHe

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

javascript replace multiline string with multiline string

From Dev

Replace string with multiline file content

From Dev

Replace string with multiline file content

From Dev

Replace text in file with multiline string

From Dev

Find and replace string spanned multiline

From Dev

Replace multiline string in all files in terminal

From Dev

Multiline string replace inside markup tag

From Dev

Search and replace all lines in a multiline string

From Dev

Replace a multiline string with pattern using sed command

From Dev

Replace a multiline string with the content of a file.txt

From Dev

OpenXML multiline string replace (regex) showing as one long line

From Dev

HTML tags replace multiline

From Dev

Global multiline search & replace

From Dev

Using sed to replace multiline

From Dev

Powershell Replace Multiline

From Dev

replace characters in string with regex JS

From Dev

Regex multiline string to string

From Dev

Javascript multiline string replacement with multiline string

From Dev

Why does removal of empty lines from multiline string in PowerShell fail using Replace function?

From Dev

Powershell regex multiline find and replace

From Dev

replace in multiline - refer to content for replacement

From Dev

Powershell regex multiline find and replace

From Dev

Multiline replace with sed - Linux/Ubuntu

From Dev

perl Multiline Find and Replace with regex

From Java

Java multiline string

From Java

TypeScript - Angular: Multiline string

From Dev

Convert multiline string to array

From Dev

Multiline string as XML

From Dev

Unindenting multiline string literals