foo must be alphanumeric
The value of this element is always a non-empty alphanumeric string of any length. The acceptable characters (other than leading and trailing whitespace) are those that match the regular expression [A-Za-z0-9]+. Leading and trailing whitespace is not significant.
Remove non-alphanumeric values from the string.
Not clear? Disagree?
You might be able to find help in one of these fine resources.