String validation

see also Regular expressions

How to check if a string includes only authorized characters
I had a few difficulties to find any function to compare a string against a pattern finally I've wrote a very simple method.

You can put it in an object or in a class for an external general use.

public boolean CheckCharsInString(str _str) {   str         char; int        pos; int        i;    container   BadChar = [';', '.',':','/','\\','!','?','-','_','&','@','\'','$','£','µ','*','%','ù','§','+','=','}','{',']','[',')','(','|','"','~','²','€'];

for (pos=0;pos<=strlen(_str);pos++) { char=substr(_str,pos,1); for (i=0;i<=conlen(BadChar);i++){ if (char == conpeek(BadChar,i)){ return(false); }       }    }    return(true); }

Ax 4.0 offers two new functions strRem and strKeep for this task: ...   str a = strRem("Hello World!", "eo"); // removes the characters "e" and "o" from given string str b = strKeep("Hello World!", "eo"); // removes everything, except for chars "e" and "o" from given string ...

Note: See the discussion for a few comments about this page regarding easier ways to achive string validation.