regex - Javascript regexp replace all <br />'s -


i'm trying replace <br /> tags appear after </h2> tag. have far:

text = text.replace(new regexp("</h2>(\<br \/\>.+)(.+?)", "g"), '</h2>$2'); 

it doesn't seem work, can help? (no matches being found).

test case:

<h2>testing</h2><br /><br /><br />text 

to:

<h2>testing</h2>text 

this simpler you're thinking out be:

text = text.replace(new regexp("</h2>(\<br \/\>)*", "g"), "</h2>"); 

Comments