Jump to content



Photo

IsNumber Bug


  • Please log in to reply
6 replies to this topic

#1 UnknownWarrior

UnknownWarrior

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 360 posts

Posted 15 January 2012 - 05:19 AM

    $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, 15 January 2012 - 05:35 AM.






#2 jaberwocky6669

jaberwocky6669

    Dull light.

  • Active Members
  • PipPipPipPipPipPip
  • 2,078 posts

Posted 15 January 2012 - 05:35 AM

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)


#3 czardas

czardas

  • Active Members
  • PipPipPipPipPipPip
  • 5,074 posts

Posted 15 January 2012 - 05:39 AM

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, 15 January 2012 - 05:40 AM.


#4 jaberwocky6669

jaberwocky6669

    Dull light.

  • Active Members
  • PipPipPipPipPipPip
  • 2,078 posts

Posted 15 January 2012 - 05:49 AM

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, 15 January 2012 - 05:49 AM.


#5 czardas

czardas

  • Active Members
  • PipPipPipPipPipPip
  • 5,074 posts

Posted 15 January 2012 - 05:58 AM

I see why that can be confusing. 'The wording is wrong' - Valik

Issue reported here

Edited by czardas, 15 January 2012 - 06:22 AM.


#6 UEZ

UEZ

    Never say never

  • MVPs
  • 3,610 posts

Posted 15 January 2012 - 08:12 AM

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, 15 January 2012 - 08:12 AM.

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#7 Malkey

Malkey

  • Active Members
  • PipPipPipPipPipPip
  • 1,297 posts

Posted 15 January 2012 - 10:41 AM

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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users