I want to replace all the string except the @[anyword]
I have string like this:
yng nnti dkasih tau :)"@mazayalinda: Yg klo ada cenel busana muslim aku mau ikutan dong "@noviwahyu10: Model ! Pasti gk blh klo k
and the @mazayalinda
and @noviwahyu10
matches my regex @\w*
.
However, I need to get rid all of the string, except for those 2 words above. We need to do the negation, but I am confuses about combining 2 regex, which are the regex to match the @[anyword]
and the one to get rid all of the sentence except those 2 words.
Any ideas?
It's not completely clear from the context if this is a viable solution, but when you want to replace everything except a certain pattern it sounds more like you want a regex search rather than a replacement. For example, in python it might look like:
Edit: in js, something like this would be more appropriate:
After this,
matches
contains all the matched strings. You can always join it back together if needed into a single string.