'matching' To String -how? Anyone?

I just want the match function to work on a string, I've searched hi and lo - declaring the string trick doesn't work -

 match "whatever", (string) ($list) ;

much appreciate any help, -M

hmm I don't get what you are exactly looking for but a lot of stuff about match is here:

http://www.highend3d.com/boards/index.php?showtopic=213550

thank you ewerybody, I've actually read thru that thread a number of times and I'll figure out the regex but basically I just care to appreciate the proper syntax for extracting a match from a string variable as opposed to from a sequence of letters, as most examples show...

[codebox]
string $sel[] = ls -sl;
string $list[] = listConnections $sel[0];
string $char = match ("whatever", ($list));
[/codebox]

I tried something similar to the casting from your thread -

[codebox]
match( "[^.]*", ( string ) ( connectionInfo -sfd smoke.color ) );
[/codebox]

and even your own trick -

[codebox]
string $fileName = file -q -location;
system ("explorer " + toNativePath(match("^.*[/]",$fileName)));
[/codebox]

but nothing works...

-- I wish there was a listCharacterSet command or flag -- or for that matter, for the ikfk setkey to actually work on any object connected to the ik in question -not just the default ones - but it doesn't, at least not in terms of setting ikfk keys.
Thus I'd like to address the ikfk controllers thru the subChar set, so as to avoid tokenizing 'n querying based on the controller name or incurring scriptjobs or generating sets -just to accommodate this annoying group selection... on the other hand, I've learned tons in the past few weeks just reading thru the threads...

thanks again, and I apologize if this is a double post but my first one failed to elicit a response...

can you give me a definite example of what you have and what you want to retrieve?
Maybe I have an Idea.

btw: match works with strings only, you cannot put stringArrays into it unless you give it an index ( $sArray[0] ).

sure, and thanks - your "btw..." my "doh!" [damn-you-array]. What tripped me was how the listConnections spurts out the connections on one long line, so if I add the index it works...

[codebox]string $sel[] = ls -sl;
string $list[] = listConnections $sel[0];
string $char = match("C.*$", ($list[2]));

returns C_arm_l_ [/codebox]

Now I just need to figure out how to match to any array-index -do I need a "for $each in" loop sort of thing? Or is there an easier way?

thanks a million btw, -M

If you want to check against each connected element, yes of course you'd need a loop.

But what do you select?
What do you want in the returned list of listConnections?
What are the names?
What do want to match to?
What if its what you are looking for?

btw: did you checkout gmatch? returns just true/false if something matches:

CODE
if (gmatch "C\_arm\_l\_blabla" "C\_*")
    print "YES!\n";

QUOTE(ewerybody @ 07/30/09, 05:18 AM) [snapback]312550[/snapback]
If you want to check against each connected element, yes of course you'd need a loop.

But what do you select?
What do you want in the returned list of listConnections?
What are the names?
What do want to match to?
What if its what you are looking for?

btw: did you checkout gmatch? returns just true/false if something matches:
CODE
if (gmatch "C\_arm\_l\_blabla" "C\_*")
    print "YES!\n";

ewerybody,

I just wanted to access/obtain the sub character node/name to automate/address/keyframe the ikfk controllers (2 joints, 1pv, 1ik and 1 switch) based on my having selected any one of the five...

to this end, I don't need the -plug flag and alas, there isn't some other flag or command to just return the 'characterSet' connection... (edit; wrong, see post below)

Like I mentioned above, the subChar is "C_arm_l_(char_name)" -assuming the C would be consecrated to this end, so matching to "C.*$" returns the full subChar name (works with namespacing too)... the big idea was to automate the IKFK switching thru a keyboard shortcut (single frame toggle), regardless of ikfk set, character-rig or referencing/namespace, simply for them being subcharacterized which they are anyway...

All this because Maya's setIKFKKeyframe does not work on all 'connect to IK' -at least not on v.2008 (and also because you can't predefine the animcurve as step tangent).

I realize I can resolve matters by creating a set and using 'listSets' but I wanted to resolve this thru the characterSet, partially cuz I wanted to learn how...

-M

p.s. blast me away if I have it coming

-YES!!! There is a better way - instead of matching, I should have been using the -type flag and specifying character -

CODE
string $sel[] = ls -sl;
string $char[] = listConnections -type character $sel[0];
string $switch[] = listConnections(($char[0]) + ".dnSetMembers[1]");

//$char[0] returns the subCharacter
//$switch[0] returns the switch controller -assuming it's always defined as the first member (which would be [1] and not [0])

I love this sh*t!! I can hereabout set a keyframe on all the IKFK controllers based on selecting any which one, then toggle the switch and set the key to step tangent, collapsing the ikfk to a true single-frame switch --and this will work as a keyboard shortcut on all ikfk systems on any and all ref'd or non-ref'd character rigs...

Hope this helps others like myself looking into Mel after years of working in Maya.... cheers, -M