Regex URL Search and Replace - 08/09/06 05:35 PM
A buddy and me are working on this little script, and we need to have like all url's that are found be changed.
every www.blah.com changed to www dot blah dot com.
http://www.blah.com changed to http://www dot blah dot com.
$replace just won't do as it replaces every occurance. We need some magic.
Been playing with this using different regex stuff (we are new to this regex) and coming up short changed:
Which results in:
http://www dot blah.com :: www dot blah.com :: www dot com :: thewww.blah.com :: thewww.com
but we want:
http://www dot blah dot com :: www dot blah dot com :: www.com :: thewww.blah.com :: thewww.com
We'd actually like it to find any .net .org etc... stuff.
Any help appreciated.
every www.blah.com changed to www dot blah dot com.
http://www.blah.com changed to http://www dot blah dot com.
$replace just won't do as it replaces every occurance. We need some magic.
Been playing with this using different regex stuff (we are new to this regex) and coming up short changed:
Code:
alias pim { var %text = http://www.cow.com :: www.cow.com :: www.com :: thewww.cow.com :: thewww.com return $regsubex(%text,/\b(www\.)\b/ig,www dot $+ $chr(32)) }
Which results in:
http://www dot blah.com :: www dot blah.com :: www dot com :: thewww.blah.com :: thewww.com
but we want:
http://www dot blah dot com :: www dot blah dot com :: www.com :: thewww.blah.com :: thewww.com
We'd actually like it to find any .net .org etc... stuff.
Any help appreciated.