PDA

View Full Version : How to "cut" a string into two subStrings?


johnchuang
12-04-2007, 02:17 PM
Hi, guys. I wonder if there is a command by which I can cut a string into two subStrings?

let's say :

string $A = "abc";
string $B;
// I want assign "a" to $B;
string $C;
// "bc" to $C;

//how can I get "a" and "bc" from $A ?

or: Can I specify a number as a start cutting point? I mean "1" for "a" and "bc" ; while "2" for "ab" and "c".

thank you!

kjaft
12-04-2007, 02:34 PM
surely man, just have a look in the online help command reference, section "strings" - plenty of string operations there. Not sure if that contains the exact thing you're searching for, if not check out the stringtools suite from highend3d: http://highend3d.com/maya/downloads/mel_scripts/utility_external/misc/StringTools-1454.html

ewerybody
12-05-2007, 08:51 AM
have a look here:

http://localhost:4449/Maya7.0/en_US/Commands/cat_Language.html#Strings
adjust your version number above^

{
string $A = "abc";
string $B = `substring $A 1 1`;
print("$B: " + $B + "\n");
string $C = `substring $A 2 3`;
print("$C: " + $C + "\n");
}

johnchuang
12-05-2007, 11:57 AM
Hi ewerybody! That's what I need . Thank you! and sorry for my careless. I should check the help more carefully , I'm quite a newbie.

Hi kjaft ! Thank you ! I find String Tools contain a bunch of cool functions , it's really handy, thank you!

ewerybody
12-05-2007, 01:43 PM
no problem! :thumbsup:
mel help is quite cool! Most people underestimate it. It helps me a lot!

CGTalk Moderation
12-05-2007, 01:43 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.