what is the regex pattern for the string '<3' and ':)'?

79 Views Asked by At

what is the regex pattern for the string

<3

and

:)

I have tried /<\s*3/g /<\d*3/g /<\.*3/g for <3 but its not working. it is matching in online regex editor but not working on my system.

el.innerHTML = el.innerHTML.replace(/<\s*3/g, '<img src="./img/heart-red.png" alt=""/> ')
1

There are 1 best solutions below

0
Rytis Dereskevicius On BEST ANSWER

Try /&lt;3/g and /(?:<|&lt;)3/g, It should work.