Game Development Community

Strip a string

by Erik Madison · in Torque Game Engine · 09/12/2004 (11:23 am) · 3 replies

I need to strip out part of a string, but in script.
ie, string = "Inventory3", I need a new string to be "3". What I'm stripping is constant and known, the remainder is not.
Help?

#1
09/12/2004 (11:32 am)
%instring = "Inventory3";
%outstring = StripChars(%instring,"Inventory");
echo(%outstring); // 3

StripChars will strip *all* occurances of the second argument so:

if %instring = "Inventory3Inventory"; %outstring would be "3"
#2
09/12/2004 (12:00 pm)
Thanks :)
#3
02/12/2009 (12:27 am)
Russell, I just want to say "I LOVE YOU MAN !!!!" =)