Check if string contains another string unordered

0 favourites
  • 5 posts
From the Asset Store
A collection of a mix of percussion and orchestral string loops, including 20 musical sketches.
  • Hello there,

    I would explain it with the examle:

    The game needs a pattern matching algorithm. E.g. there's a list of all possible patterns as 2d array coordintates (as string):

    Here's one possible pattern:

    0,1 0,2 0,3 1,1 1,2 1,3

    Than I have a set of 2d array coordinates, that I would like to check if it contains a pattern from the list (the string above):

    5,4 0,0 0,1 0,2 0,3 0,4 1,1 1,2 1,3

    How to check if the 2nd string contains all the pairs from the first string, despite of order of pairs?

  • You could use the system expression

    find(src, text)

    Find the first index within src that text occurs, else returns -1.

    So if the result of that expression is something else than -1 the pattern exists within the text.

  • Ah, this will only work if both strings are exactly the same or pairs have the same order. I think may be Regex could help, but the biggest problem here is the order of pairs, the search should be unordered.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you only want to check if the pair exists within the string they dont have to be the same? if not -1 it exists.

    But probably I don't understand what you are trying to accomplish.

  • Ok, I thought it would be possible to check the whole string at once, but I had to do it for each pair - it works like this.

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