UnknownWarrior Posted January 15, 2012 Share Posted January 15, 2012 (edited) $domain = StringSplit($domain, ".") Do $i += 1 MsgBox(0,"", IsNumber(StringMid($domain[2], $i, 1)) & " " & StringMid($domain[2], $i, 1)) Until IsNumber(StringMid($domain[2], $i, 1)) = 1 So I'm trying to parse some domains that have numbers after the TLD extension. The domain for the example is: asianculturalmediagroup.com2360 My script correctly finds the #'s as I want, but IsNumber WILL NOT WORK. I've tried everything possible After I find what position ($i) that the number is at, I then can trim the rest of the numbers accordingly - which would result in just the domain itself. Any ideas? >< P.S. - My MsgBox debugger is showing a #, but the IsNumber is still returning a '0' (False). I also wrote down the StringMid results in a text file and they are all showing up as #s as well with no added characters. Edited January 15, 2012 by UnknownWarrior Link to comment Share on other sites More sharing options...
jaberwacky Posted January 15, 2012 Share Posted January 15, 2012 All you want for your first question is to lob off the numbers off the end? If so then:#include <Array.au3> Global $domain = "asianculturalmediagroup.com2360" $domain = StringSplit($domain, ".com", 1) _ArrayDisplay($domain) Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
czardas Posted January 15, 2012 Share Posted January 15, 2012 (edited) It's not a bug. StringMid() returns a string, which is never a number. I would use StringIsDigit() for this. $domain = StringSplit("asianculturalmediagroup.com2360", ".") $i = 0 Do $i += 1 MsgBox(0,"", StringIsDigit(StringMid($domain[2], $i, 1)) & " " & StringMid($domain[2], $i, 1)) Until StringIsDigit(StringMid($domain[2], $i, 1)) Edited January 15, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jaberwacky Posted January 15, 2012 Share Posted January 15, 2012 (edited) Helpfile says: "Variants can be of two base types: Strings and Numbers." I always took that to mean that '1' is a number as well as 1. Edited January 15, 2012 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
czardas Posted January 15, 2012 Share Posted January 15, 2012 (edited) I see why that can be confusing. 'The wording is wrong' - Valik Edited January 15, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
UEZ Posted January 15, 2012 Share Posted January 15, 2012 (edited) Try this: $url = "789asiancultural123mediagroup.com2360" ;idea 1 $n = StringRegExp($url, "(d+)Z", 3) MsgBox(0, "Idea 1", "Url: " & StringMid($url, 1, StringLen($url) - StringLen($n[0])) & @LF & "Port: " & $n[0]) Sleep(250) ;idea 2 $l = StringLen($url) $i = $l Do $s = StringMid($url, $i, 1) $i -= 1 If Not StringIsInt($s) Then ExitLoop Until False MsgBox(0, "Idea 2", "Url: " & StringMid($url, 1, $i + 1) & @LF & "Port: " & StringRight($url, $l - $i -1)) Br, UEZ Edited January 15, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Malkey Posted January 15, 2012 Share Posted January 15, 2012 Here is one more - a continuation of UEZ's example. $url = "789asiancultural123mediagroup.com2360" MsgBox(0, "Idea 3", _ "Url: " & StringRegExpReplace($url, "(\d+)$", "") & @LF & _ ; Remove trailing digits. "Port: " & StringRegExpReplace($url, "(.*\D+)", "")) ; Return only trailing digits. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now