Split Function Needed!

0 favourites
  • 3 posts
From the Asset Store
Template for dungeon/maze generation, using wave function collapse
  • type: General Function

    expression: Split(string1, string2, index)

    example usage:

    MyString1 = "hi;hello;hey"

    MyString2 = Split(MyString1, ";", 0) - (Would return "hi")

    MyString2 = Split(MyString1, ";", 1) - (Would return "hello")

    MyString2 = Split(MyString1, ";", 2) - (Would return "hey")

    what it does:

    string1 is the string to split

    string2 is the string/character to split string1 by

    index is the index of the split to return

    another example:

    Str1 = "mr,mrs,miss"

    Str2 = Split(Str1, ",", 1) - would return "mrs"

    Hope this is understandable!

    Thank-you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

    System expressions in the manual

    Unless I missed something.

  • Yeah, as Kyatric posted, there's even an expression to get the number of tokens.

    tokencount(src, separator)

    Count how many tokens occur in src using separator. For example, tokencount("apples|oranges|bananas", "|") returns 3.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)