Folks,
I have method that returns true if all characters are "legal" and false if a single character is "illegal". The definition is below (legal = letters, numbers, and some characters like $, - , %, etc). I want a newline and/or carriage return character to be "illegal". However, the method below thinks that its legal. How can I fix-up?
private static bool NameHasAllLegalCharacters( string name )
{
var regexAlphaNum = new Regex( @"[^a-zA-Z0-9#\$%\^&\*\(\)\._\-\+=\[\]/<>{}:\s]" );
return !regexAlphaNum.IsMatch( name );
}