Jump to content

IsNumber Bug


Recommended Posts

$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 by UnknownWarrior
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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 by czardas
Link to comment
Share on other sites

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 by LaCastiglione
Link to comment
Share on other sites

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 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...