Wildcard searching in IF-ELSE statements?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
Old 04 April 2009   #1
Wildcard searching in IF-ELSE statements?


I´m having a little problem here

Take a look at this

 string $test = "test_knee_test";
 if($test == "*_knee_*")
 	print "Yes";
 else print "No";

I want it to return Yes, but it doesn´t. Shouldn´t it?

If i do a search in maya like this:
select -r ("*_knee_*");

That selects what I want ...

... so why is not the if-statement working?

// Otto
Old 04 April 2009   #2
because == is for exact comparison, i.e _knee_ == _knee_

if you want to use *, then use gmatch command.

if(`gmatch $test "*_knee_*"`)
Old 04 April 2009   #3
Thank you Jefri, great!

Old 04 April 2009   #4
Or use the "match" command as it will allow you to use more in depth regular expressions for hunting string matches
Old 04 April 2009   #5
Okey, will try that too, thanks Free4
Old 04 April 2009   #6
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 02:56 PM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.