I have a string:
“Gazelles were mentioned by @JohnSmith while he had $100 in his pocket and screamed W#$@%@$!!!!"
I need:
“Gazelles were mentioned by @JohnSmith while he had 100 in his pocket and screamed"
How to remove all special characters from string EXCEPT the @ symbol. I tried:
str.replace(/[^\w\s]/gi, '')
[^\w\s@]@only when it is followed by a word char?(?:[^\w\s@]+|@(?!\w))@(?!\w)|[^\w\s@]for example. Pretty much what @TheFourthBird mentioned earlier.\sin the negated character class makes it not match a newline. It could be like this for example[^\w \t@]+|@(?!\w)regex101.com/r/2fM0LK/1