Wildcards in strings

This forum is currently in read-only mode.
From the Asset Store
This collection of music is the beautiful performance of rather small strings ensemble (8 first violins, 6 second violin
  • Hello

    Is there anyway to match two or more strings of which one contains one or more wildcards, for example if I want to compare strings "abbdfsgg" and "abgdklgg" with string "ab*d**gg" (no that is not some exotic curse word) and return true for both? Is this possible and if yes, what would I use for wildcard character and how would I write it in the expression? I have tried both asterisks and question marks, but none of them seems to work. I hope you understand what I mean.

  • I don't think there's a buildin way to do what you requested. But by using some of the text expressions you could invent your own method to achieve this with events.

    I cooked up an example for you:

    http://dl.dropbox.com/u/2306601/wildcards.cap

    Enter the string you want tested in the editbox and click on the compare button. It will return either true or false. The text object named "Rule" holds your compare string with the wildcard characters (I used "$" as a wildcard). I'm sure this isn't the most elegant way to do this, but it appears to work fine.

    I'm using a loop and some expressions. Seeing that this is your first post, I hope you can make sense of it all. You can always look up stuff on the Construct wiki.

    And welcome to the community! Great avatar you have there...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A million thanks to you good sir.

    I think understand what's happening. Basically you divide the rule string using $ as the delimiter and then loop through each snippet comparing it to the first same number of letters in the input string and then you delete the length of the snippet plus one character, the delimiter, from the input string. That should work perfectly for what I'm trying to do.

    Thanks for the help and thanks for the warm welcome

  • I think understand what's happening. Basically you divide the rule string using $ as the delimiter and then loop through each snippet comparing it to the first same number of letters in the input string and then you delete the length of the snippet plus one character, the delimiter, from the input string.

    Couldn't have said it better myself!

    Thanks for the help and thanks for the warm welcome

    My pleasure!

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