Posted: 10/20/2010
Hi,I have a textbox in my form I need a regex to check for blank space in that textbox value. How can I make it ?
#region Using Directives using System; using System.Text.RegularExpressions; #endregion public class Example { static void Main() { string input = "hello"; string regex = @"^[\S]*$"; bool isMatch = false; isMatch = Regex.IsMatch(input, regex); Console.WriteLine(isMatch ? "{0}: Matched" : "{0}: Not Matched", input); input = "hello good"; isMatch = Regex.IsMatch(input, regex); Console.WriteLine(isMatch ? "{0}: Matched" : "{0}: Not Matched", input); Console.ReadLine(); //Output: //hello: Matched //hello good: Not Matched } }