Game Development Community

Strip everything except alphanums?

by Jason McIntosh · in Torque Game Builder · 05/11/2005 (7:14 pm) · 4 replies

Is there an easy way to strip out all characters from a string that are not alphanumeric? Ie, some handy built-in function? :) I know how to do it one character at a time, but I want to make sure the work isn't already done for me in the engine.

#1
05/14/2005 (8:38 pm)
There is documentation on strToPlayerName(string); but it does not seem to work for me. It supposedly limits a string to 16 characters, strips leading spaces, underscores, and , . \ and ' from the string. So it really wouldn't be sufficient for what you want to do anyway.
#2
05/14/2005 (9:22 pm)
For now I'm doing a bunch of stripChars() calls, which works but is far from elegant or compact. Thanks for the reply.
#3
05/15/2005 (8:51 am)
Is there something resembling regular expressions available in the T2D code? Because it's rather straightforward using that. If there isn't, I'd be amazed if there wasn't an open C++ lib out there.
#4
05/15/2005 (9:33 am)
Well, soon there will be Python for T2D (right, Jeremy and Tomas?!), and it won't be a problem anymore. :)