I have regular expression allow only latin letters and digitals number and disallow space. But this expression miss string where exist space. In my code I need see true and false. But I see true and true. How it fixed?
String str1="5asdfEDadgs2";
String str2 = "5 asdfgsadgs2";
String reg=@"^[a-zA-Z]|[0-9]|.*$"
bool res = Regex.Match(str1,reg). Success; //Must show true
bool res2 = Regex.Match(str2, reg).Success; //Must show false
Console.WriteLine(res);
Console.WriteLine(res2);