Example Text:
<div id="not-wanted">
no no
no
</div>
<div id="wanted">I want
only this
text
</div> no no no
no no
<div id="not-wanted">
no no no
</div>
<div id="wanted">no no
no no</div>
<div id="wanted">
no no
</div>
Should deliver:
I want
only this
text
Or better:
I want only this text
Unfortunately, my solution catches the 2 delimitation strings also:
$('#put').append(/<div id="wanted">[^<>]*<\/div>/.exec(strg)[0]);
==>
<div id="wanted">I want
only this
text
</div>
Online example
http://regex101.com/r/rF7jR9
Question
What regular expression for Java Script can deliver the characters between delimiting strings, if there are also \n
and \r
resend. It would be nice, if \n
and \r
are removed from the delivered string. The RegExpr should work fast.