mIRC Home    About    Download    Register    News    Help

Print Thread
#226033 16/09/10 09:26 AM
Joined: May 2006
Posts: 98
L
Lloyd_B Offline OP
Babel fish
OP Offline
Babel fish
L
Joined: May 2006
Posts: 98
I'm looking for help in isolating the TLD (top level domain) from /whois data. I already have part of the script but I lack the part to get just the TLD from the whois data. Could someone please help me with this?

I can't just use a script to just take the last three letters because people from many different places and around the world visit my channel. So, sometimes it's a two letter country code, sometimes it's three letters, sometimes four, etc.. So, I just want the very last letters after the last dot.

In case an example is needed, this is what I want:

JohnSMith is jsmith@blahblah.blahblah.com
or
JohnSMith is jsmith@blahblah.blahblah.ac

I just want the .com or .ac but without the "." dot.


Lloyd
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Just isolate the host part and do a $gettok(host,-1,46) and maybe check if it's not a number (in cases where the host is an IP address).

Joined: May 2006
Posts: 98
L
Lloyd_B Offline OP
Babel fish
OP Offline
Babel fish
L
Joined: May 2006
Posts: 98
Oh man, thank you so much. I'm still learning scripting so I didn't know about $gettok yet. That should do the trick.


Lloyd
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
$gettok is one of the most used identifiers when dealing with strings. wink

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
just for added information, there's also $deltok(string, 1--2, 46) which is subtly different from the above in that it will return $null if there is only 1 single period delimited token in the string. that may or may not be desirable if even relevant in this case!


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: May 2006
Posts: 98
L
Lloyd_B Offline OP
Babel fish
OP Offline
Babel fish
L
Joined: May 2006
Posts: 98
I appreciate the help from both of you. I just tested it out and it's working fine.

I already had a part of my script that looks for numbers. However, it works better now.

To: 5618
I can see why it's commonly used, it's a handy little bit for this kind of thing. Thanks to you I know a little more.

Last edited by Lloyd_B; 17/09/10 01:52 AM.

Lloyd

Link Copied to Clipboard