I want to strip the following out of a string:
- http://
- https://
- www.
- www2.
- /
An example string would be 'http://www.google.com', and I need to strip both 'http://' and 'www..'
I am trying to do this via Javascript's replace() using regex:
string.replace(/http:\/\/|www\.|www2\.|\//i,"");
The problem I'm encountering is that it will only strip one match from the regex. For example, in the above string only 'http://' would be removed.
Have I got the regex wrong or is replace only able to match once? I tested my expression on an online, non-JS regex builder and it worked fine.
Any help would be appreciated! Thanks!