What I need is something that will match words that contain special symbols (except ?, ! and .) and URL’s.
Here’s what I already have, but it doesn’t quite work.
re = new RegExp('(http://\S+|\S*[^\w\s,.":]\S*)');
text = '@hello how are you? http://example.com';
clean = text.replace(re, '');
The current output is:
> 'hello how are you? http://example.com'
The output should be:
> ' how are you? '
You need to use global in the RE
I also added “?” to your set since it seems you want that included.