I know my question might look like a duplication for this question, but its not
I am trying to match a class name inside html text that comes from the server as a template using JavsScript RegExp and replace it with another class name.
here what the code looks like :
<div class='a b c d'></div>
<!-- or -->
<div class="a b c d"></div>
<!-- There might be spaces after and before the = (the equal sign) -->
I want to match the class "b" for example
with the highest performance possible
here is a regular expression I used but it's not working in all cases, and I don't know why :
var key = 'b';
statRegex = new RegExp('(<[\w+ class="[\\w\\s]*?)\\b('+key+')\\b([\\w\\s]*")');
html.replace( statRegex,'SomeOtherClass');// I may be mistake by the way I am replacing it here