Replace all URL unless it is allowed
Posted
by
ratamaster
on Stack Overflow
See other posts from Stack Overflow
or by ratamaster
Published on 2012-11-20T04:38:58Z
Indexed on
2012/11/20
4:59 UTC
Read the original article
Hit count: 135
I had a regex that replaced all URLs from a given string:
my_string = "www.example.com test www.mysite.com"
my_string.gsub!(/[a-zA-Z0-9\-\.]+\.(com|net|de|org|uk|biz|info|co.uk|es|de)(\/\S*)?/i,'(site hidden)')
As a result of the above I get: "(site hidden) test (site hidden)"
How could I change the regex to not replace www.mysite.com ???
It means that the replace should output "(site hidden) test www.mysite.com"
Thanks !
© Stack Overflow or respective owner