Parsing an IP address. (SOLVED)

0 favourites
  • 1 posts
  • Ok, screw the tokenat. Found a working solution with regex.

    "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$"

    Here's what I have and it mostly works. The theory, if the text input is a valid IPV4, it sets the opacity of a search sprite to 100%, otherwise it sets the opacity to 50%. The problem is, if a user enters a.a.asd.aawd It's seeing those as integers. I've tried various combinations of !NaN and checking to see if it is an integer and it always evaluates the character as a valid integer.

    What am I forgetting??

    Thanks!

    * On function 'CheckIP'

    ----+ System: tokencount(IPInput.Text, ".") = 4

    --------+ System: Repeat tokencount(IPInput.Text, ".") times

    ------------+ System: tokenat(IPInput.Text,LoopIndex, ".") > ""

    ----------------+ System: int(tokenat(IPInput.Text,LoopIndex, ".")) ≤ 255

    -----------------> IPSearchIcon: Set opacity to 100

    ----------------+ System: Else

    -----------------> IPSearchIcon: Set opacity to 50

    -----------------> System: Stop loop

    ------------+ System: Else

    -------------> IPSearchIcon: Set opacity to 50

    -------------> System: Stop loop

    ----+ System: Else

    -----> IPSearchIcon: Set opacity to 50

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)