Hi,
For starters "=~" means do the substitution on and assign back to.
\A means Matches at the beginning of the string.
Taken literally, the whole thing is...
Line 1 : Sets up a lowercase version of the variable to work on from a hash -that seems to be some sort of URL.
Line 2 : Substitute out (ie. replace with with nothing) everything up to and including the last // - its a greedy match.
Line 3 : Substitute out starting with www., the www.
Line 4 : This is a bit trickier. The Substitution goes... Starting with (ie. the \A) zero or one anythings non-greedily up to but not including the /rest-of-the-URL with the first bit.
Its a URL being worked on, so essentially its taking off the http:// then the www. and then dropping everything off after next /
So... it produces the the domain name.
eg. http://www.microsoft.com
would yield microsoft.com
eg www.microsoft.com/products/default.html
would still yield microsoft.com
If you're having problems with it, it could be that the following substition would occur - due to the first greedy match...
www.microsoft.com/question.jhtml?product=slashmaker//
Would yield a blank string (I think - without having actually tested it...)
...but I dont know if that syntax would be a possible "HTTP_REFERER"?
Hope this helps,
Cheers,
Tim.