Get Off My Lawn
Get Off My Lawn

Reputation: 36309

Replace string between two items

Fairly simple question, how can I replace \n with {br} between two <blockquote> and </blockquote> tags?

thought this would work, but it doesn't:

val = val.replace(/<blockquote>\b\n\b<\/blockquote>/igm, "{br}");

Upvotes: 0

Views: 120

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324630

Use a replacement callback:

val = val.replace(
    /<blockquote>[\s\S]*?<\/blockquote>/i,
    function(m) {return m.replace(/\n/g,"{br}");}
);

Upvotes: 4

Related Questions