PDA

View Full Version : Help with regular expression needed! +


Nenox
10-18-2005, 03:55 PM
Hi.

I have a string array containing names of attributes connected to a multiMessageAttribute. I want to get the names of the nodes that the attributes belong to (full path). Is there a way to do that?

As an alternative i've tried to extract the name by using a regular experssion, eg. by extracting the name "rShoulder" from "rShoulder.message", using this command:

match "[A-Z a-z _]*" "rShoulder.message".

This only gives me the shortName, wicth is not optimal. Also I am not shure if Maya node names can contain other characters than the ones stated in the expressions.

Also i initialy wanted to make a regularexpression, that returned everything before the character ".", but did not know how.

Ok, a mess and many questions! Hope you guys can give me some pointers!

Thanks :-)

mhovland
10-18-2005, 05:22 PM
Try this link out, and see if it has what you need. I haven't looked, but this is my first stop for regular expression help.

http://www.ewertb.com/maya/mel/mel.php?howto=94

Nenox
10-18-2005, 05:40 PM
Thanks - That usefull stuff indeed!

Anybody know how to get the long path transform name based on a connection, as talked about above?`

Cheers

Nenox
10-18-2005, 07:41 PM
Ok, my bad!

This gives you eg: pCube1

listConnections -destination false -source true niels_characterNode.baseSkeleton;

But i had used the -plugs flag: pCube1.message

listConnections -plugs true -destination false -source true niels_characterNode.baseSkeleton;

Thanks anyway! :-)

mhovland
10-18-2005, 07:50 PM
Instead of using a regular expression, I would tokenize out the name like so:

string $hold[];
int $numT = `tokenize "rShoulder.message" "." $hold`;


Now just use ls to get the full path


ls -l $hold[0];


Does that do what you want?

Nenox
10-18-2005, 11:15 PM
Yeah, that looks cool!

Tokonize was the first thought I had as well. But then again, i don't really need the bit after the ".", and i'm using it in a loop, soo I found a nice regular exp. on the page you posted, that good for code economy: Eg. match "^[^\.]*" "janus.message".

But what I needed was the full path and listConnections (That I have to use anyway) actually returns it, with the right flags. Soo I'm good for now, but nice to be prepared for next time.

Thanks a million man!
Cheers

CGTalk Moderation
10-18-2005, 11:15 PM
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.