How can I remove \"www\", \"http://\", \"https://\" from strings using Ruby?
I tried this but it didn\'t work:
s.gsub(\'/(?:http?:\\/\\/)?(?:www\\.)?
s = s.sub(/^https?\:\/\//, '').sub(/^www./,'')
If you don't want to use s =, you should use sub!s instead of all subs.
The problems with your code are:
sub instead of gsub and ^ in the beginning of Regexp so it only replaces the http:// in the beginning but leaves the ones in the middle.