I need a javascript regular expression to get all words that starts with ! and then is followed by any number of alpha-numerics
for example if I have a text like
!google I don't like you I prefer !bi3g or !yahoo
I need a regular to return (“!google”, “!bi3g”, “!yahoo”)
I have this regular expresion /\![a-z0-9 &-_] /gi that will work perfectly in the case where the word is not followed by \n or isn’t the end of the text, so applying it to the previous text it won’t return “!yahoo”
I know that using \b\b will return all words including the ones followed by \n and the last word in the text can anybody help me how to set my regular expression to return all words inculding those follwed by \n and the last word in the text using \b\b.
To also remove the
!signs you can run(Note,
map()is a feature of ECMAScript Edition 5; if you need support for IE <= 8 there are other ways of removing the!).