RegEx: Want to check for missing text.

T

Thief_

I'd like to check if a textbox contains text & symbols. Sometimes it will
have just carriage returns and/or spaces, and lots of them, and I want to
check if this is the case so that I can clear the multi-line textbox. What's
the RegEx expression for this?

VB.NET2003
 
L

Larry Lard

Thief_ said:
I'd like to check if a textbox contains text & symbols. Sometimes it will
have just carriage returns and/or spaces, and lots of them, and I want to
check if this is the case so that I can clear the multi-line textbox. What's
the RegEx expression for this?

^\s*$

will match a string consisting entirely of whitespace characters.
Whitespace characters are: Space, Tab, Formfeed, Newline, Carriage
return, Vertical tab. If you only want to match some of these for some
reason, they all have their own regex code: they are respectively (a
single space), \f, \n, \r, \t, \v. So if you only wanted to match
spaces and tabs you would use

^[ \t]*$
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top