// don't ask me how exactly, but this gets the main domain froma hostname;
This explains a lot. What I don't understand though, is why this guy, who doesn't understand basic regular expressions (the expression is also wrong), is working on the American Express website.