Похожие чаты

Hey guys! I'm trying to delete all the ":-)" symbols in

the string but it doesn't work with symbols for some reason
var str1=prompt("Введите строку:", );
var str2=":-)";
str1 = str1.replace(/:-)/gi, "");

when I add letters instead of symbols like str1 = str1.replace(/a/gi, ""); it works
does anyone know the problem? sorry if my question is dumb, I'm a beginner

5 ответов

14 просмотров

Please format the code you posted, by wrapping it in triple backticks. -> `

you're escaping it wrong

/:\-\)/gi

Liana-Batalova Автор вопроса

what if I have a string ":-)))))" and I don't know the amount of brackets but all the brackets which follow after ":-)" like "abcd:-)))))ef)tg" need to be deleted so the result will be "abcdef)tg"?

Would need to escape RegExp symbols

Похожие вопросы

Карта сайта