Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7129
| References | <d30814aa-494f-457f-8a56-5ebe802f4725@z7g2000prh.googlegroups.com> |
|---|---|
| Date | 2011-06-07 12:50 +1000 |
| Subject | Re: Validating string for FDQN |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2516.1307415025.9059.python-list@python.org> (permalink) |
On Tue, Jun 7, 2011 at 10:40 AM, Eric <eric.wong.t@gmail.com> wrote: > Hello, > > Is there a library or regex that can determine if a string is a fqdn > (fully qualified domain name)? I'm writing a script that needs to add > a defined domain to the end of a hostname if it isn't already a fqdn > and doesn't contain the defined domain. One reliable way to test would be to do a whois check on the name. If it comes up with something, it's fully qualified. http://code.google.com/p/pywhois/ Alternatively, if all you want is a simple syntactic check, and if you can assume that the name is already a valid domain name (no weird characters, etc), then you can simply divide it on the last dot and see if the last part is a recognized TLD. A partial list of TLDs can be found here: http://data.iana.org/TLD/tlds-alpha-by-domain.txt There are other TLDs too, including .localhost and .test, which you can probably ignore. Chris Angelico
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Validating string for FDQN Eric <eric.wong.t@gmail.com> - 2011-06-06 17:40 -0700
Re: Validating string for FDQN harrismh777 <harrismh777@charter.net> - 2011-06-06 20:55 -0500
Re: Validating string for FDQN Chris Angelico <rosuav@gmail.com> - 2011-06-07 12:50 +1000
Re: Validating string for FDQN Philip Semanchuk <philip@semanchuk.com> - 2011-06-06 23:10 -0400
Re: Validating string for FDQN Nobody <nobody@nowhere.com> - 2011-06-07 06:23 +0100
Re: Validating string for FDQN Chris Angelico <rosuav@gmail.com> - 2011-06-07 15:52 +1000
Re: Validating string for FDQN Chris Torek <nospam@torek.net> - 2011-06-07 06:20 +0000
Re: Validating string for FDQN Nobody <nobody@nowhere.com> - 2011-06-07 21:46 +0100
csiph-web