Question: Suppose I got these urls.

```
http://abdd.eesfea.domainname.com/b/33tA$/0021/file
http://mail.domainname.org/abc/abc/aaa
http://domainname.edu 

```

I just want to extract "domainame.com" or "domainname.org" or "domainname.edu" out.
How can I do this?

I think, I need to find the last "dot" just before "com|org|edu..." and print out content from this "dot"'s previous dot to this dot's next dot(if it has).

Need help about the regular-expres.
Thanks a lot!!!
I am using Python.

Answer: 
why use regex?

<http://docs.python.org/library/urlparse.html>
In addition to Jase' answer.
If you don't wan't to use urlparse, just split the URL's.

Strip of the protocol (http:// or https://)
The you just split the string by first occurrence of '/'. This will leave you with something like:
'mail.domainname.org' on the second URL. This can then be split by '.' and the you just select the last two from the list by [-2]

This will always yield the domainname.org or whatever. Provided you get the protocol stripped out right, and that the URL are valid.

I would just use urlparse, but it can be done.
Dunno about the regex, but this is how I would do it.