I tried to use regex replace method to replace xxx="yyy" pattern of text in given string like.
My pattern is : /^[a-zA-Z0-9.;:|_-]+="[a-zA-Z0-9.;:_-]+\"/
Code:
var userinput = '<div id="c16430" style="color:red;" class="css-btn">';
var pattern = /^[a-zA-Z0-9.;:|_-]+="[a-zA-Z0-9.;:_-]+\"/;
userinput = userinput.replace( pattern, "Replaced..." );
But it is not working... jsfiddle. What is wrong?
Thanks in advance..
^is used to say that you're search at the beggining of the subject, in your case, it have not to be used because you're search any place of the string.