Remove non alphanumeric characters with MLQ4

 

How can I remove all non-alphanumeric characters?  This does not work:

Alert( AlphaNumeric("Hello 123 !@# WORLD") );

 ///// FUNCTION

void AlphaNumeric (string istr)   {
  string other="Aa";
  string ostr = "";
  for (int i=0; i<StringLen(istr); i++)  {
    string s = StringSubstr(istr,i,1);
    if ((s >= "A" && s <= "Z" && StringFind(other,"A") >= 0) 
    ||  (s >= "a" && s <= "z" && StringFind(other,"a") >= 0) 
    ||  (s >= "0" && s <= "9" && StringFind(other,"1") >= 0) 
    ||  StringFind(other,s) >= 0)
      ostr = ostr + s;
  }    
  return(ostr);
}  

 

 I get an error:

'AlphaNumeric' - function returns no result

 


 
hknight:

How can I remove all non-alphanumeric characters?  This does not work:

 

 I get an error:

'AlphaNumeric' - function returns no result

 



You need to define the function so it returns a string, not void

string AlphaNumeric (string istr)
 

Thanks!