Wildcards in strings

For questions about using Classic.

Post » Wed Apr 14, 2010 6:43 pm

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.
B
1
G
2
Posts: 4
Reputation: 633

Post » Thu Apr 15, 2010 4:13 pm

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:
[url:2jfl67j5]http://dl.dropbox.com/u/2306601/wildcards.cap[/url:2jfl67j5]

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... :)
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Fri Apr 16, 2010 8:35 am

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 :D
B
1
G
2
Posts: 4
Reputation: 633

Post » Fri Apr 16, 2010 8:11 pm

[quote="Mr Mustachio":16ls8wry]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.[/quote:16ls8wry]

Couldn't have said it better myself!

[quote="Mr Mustachio":16ls8wry]
Thanks for the help and thanks for the warm welcome :D[/quote:16ls8wry]

My pleasure! 8)
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests