CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 03-28-2003, 04:25 AM   #1
twidup
zombie slaying rugby plyr
 
twidup's Avatar
portfolio
Todd Widup
Sr Creature TD
movielocation
Cardinal Pier, United Kingdom
 
Join Date: May 2002
Posts: 974
searching a string array

is there a way to search a string array for a set string?

example: I have an array of all the referenced files used in the current scene. I am looking for a specific one to change the name on.

my current idea is to get the array that file -q -r creates, then create a new string with all the array components, then tokenize that by part of the name I am looking for, then tokenize that with a variable I set in the string to seperate the array comp. with.

and then grab the last part of the new array, as that would be the path I am looking for.

is there an easier way that I am missing?


Cheers,
-Todd
__________________
Good . . . Bad . . . I'm the guy with the gun.
-Ash

<.|.. My comments are not those of my employer(s)

Last edited by twidup : 03-28-2003 at 04:55 AM.
 
Old 03-28-2003, 08:21 AM   #2
bigfatMELon
Seer
 
bigfatMELon's Avatar
Blizzard
 
Join Date: May 2002
Posts: 340
Send a message via AIM to bigfatMELon
ArrayTools and StringTools on Highend3D.

the itemInStringArray function:

string $myTestArray[] = {"blue", "green", "red"};
//string $myTestString = "green";
//itemInStringArray $myTestString $myTestArray;

the stringNthWord function:

stringNthWord "left_wrist_controller" 2 "_";
// Result: wrist //

the stringRepalceNthWord function:

stringReplaceNthWord "hello world." "mellow" 1 " ";
// Result: mellow world. //

-jl
 
Old 03-28-2003, 08:49 AM   #3
twidup
zombie slaying rugby plyr
 
twidup's Avatar
portfolio
Todd Widup
Sr Creature TD
movielocation
Cardinal Pier, United Kingdom
 
Join Date: May 2002
Posts: 974
hmmm, those are helping a bit, gonna have to read thru them a bit...I am also only searching for a protion of the whole string.
__________________
Good . . . Bad . . . I'm the guy with the gun.
-Ash

<.|.. My comments are not those of my employer(s)
 
Old 03-28-2003, 08:49 AM   #4
sedric
mayanizer
 
sedric's Avatar
character TD / rigging dood
 
Join Date: Jul 2002
Posts: 145
Send a message via ICQ to sedric
would this work?

string $thing
string $things[]

for ($thing in things)
{
if ($thing = sumfin) do something to $thing
}
__________________
check out my portfolio web site!

Click Here and see!
 
Old 03-28-2003, 09:22 AM   #5
twidup
zombie slaying rugby plyr
 
twidup's Avatar
portfolio
Todd Widup
Sr Creature TD
movielocation
Cardinal Pier, United Kingdom
 
Join Date: May 2002
Posts: 974
Sedric, thanks, I will give that a try...and thank you too Melon

Cheers
__________________
Good . . . Bad . . . I'm the guy with the gun.
-Ash

<.|.. My comments are not those of my employer(s)
 
Old 03-31-2003, 10:25 AM   #6
mark_wilkins
Scream.
 
mark_wilkins's Avatar
 
Join Date: Jan 2003
Posts: 1,339
Note that you might (MIGHT, not definitely) get into trouble using the == operator on strings, because == is intended for use with numeric values. The strcmp function checks for string equality.

Anyway, you can loop over the strings in your array and use the "match" or "gmatch" commands to find substrings. "gmatch" is the easiest, because if you want something that contains "foo" you can use the search string "*foo*". The match command requires that you know regular expressions.

-- Mark
__________________
Mark R. Wilkins
author of MEL Scripting for Maya Animators
 
Old 01-14-2006, 07:00 PM   #7
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 01:52 PM.


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