I'm trying to remove a wrapper around a button using RegExr, but it returns a null value.
I used the solution of this question, like so:
var title = $( ".redButton" ).text();
var myString = $( "#content" ).html();
var myRegexp = /(<p>\s<button class"redButton">)((?:\s|.{1,50})*)(<.button>\s<.p>)/g;
var match = myRegexp.exec(myString);
console.log(match);
so i can eventually turn this:
<article id="content">
<p>
<button class="redButton">EEN HELE LANG TITEL IN EEN KNOP</button>
</p>
</article>
into this:
<article id="content">
<button class="redButton">LONG TITLE IN A BUTTON</button>
</article>
Before I continued I wanted to check if the RegEx worked, which it apparently doesn't. This solution would fix the problem, using escapes, but I don't understand when I should and when I shouldn't escape.
Can anyone help?