0

I'm looking for a regex pattern that matches the following values:

  • an empty string, or
  • a string that contains only spaces.

Thanks

1 Answer 1

3

You could use this regex:

/^\s*$/

Start of string 
Followed by zero or more whitespace 
End of string
Sign up to request clarification or add additional context in comments.

1 Comment

+1 for being faster (accursed minimum-character count hold-up..!), and explaining.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.