Skip to content Skip to sidebar Skip to footer

Parenthesis Not Being Replaced In Regex

I know there are many ways over the internet but this case is a special one. I need to replace :) with . And str.replace(/:)/g,'img src='smiley.gif'')

Solution 1:

You have to escape the parenthesis:

str.replace(/:\)/g, '<img src="smiley.gif">');

Post a Comment for "Parenthesis Not Being Replaced In Regex"