Tintin81
Tintin81

Reputation: 10207

Is there a Regular Expression for blank input?

This might be a silly question but is there a Regular Expression to validate for blanks or no user input at all?

Upvotes: 3

Views: 13725

Answers (2)

Pavel Anossov
Pavel Anossov

Reputation: 62908

Start of line immediately followed by end of line:

^$

Any amount of whitespace, including none:

^\s*$

Upvotes: 9

alecxe
alecxe

Reputation: 473873

^$ should do the trick. ^ matches the beginning and $ the end of the string.

Upvotes: 4

Related Questions