//
// removeInvalid: takes an input string and returns a valid
// DAG name string (alpha-numerics only)
//
// $mode: 0=strip , 1=replace_
global proc string removeInvalid(string $input, int $mode)
{
string $output = "";
for ($n = 1 ; $n < size($input)+1 ; $n++)
{
string $char = `substring $input $n $n`;
if ($n == 1 && `match "[0-9]" $char` != "")
$output += ("_"+$char);
else if (`match "[a-zA-Z0-9_]" $char` != "")
$output += $char;
else if ($mode)
$output += "_";
}
return $output;
}
February 5, 2009
Syntax Testing
2 Comments »
RSS feed for comments on this post. TrackBack URL
I know this was posted a few years ago so you may not be keeping up with it, but I was wondering if you could query the value of a textfield, strip it of invalid characters and re-input the valid character string to the field?
Comment by Raiyan Haq — October 23, 2013 @ 1:05 pm
sure you can, it’s a piece of cake in both MEL and Python, what exactly would you like to know about doing it? email me at nathan@(this.domain) if you like and we can discuss it properly.
Comment by Naughty — October 23, 2013 @ 8:26 pm