RegEx to allow anything except blanks or all spaces?

regex

Solution

How about this regex:

(?!^ +$)^.+$

This will make sure that:

- Input is not empty or null

- Input doesn't only have 1 or more spaces

- Spaces in between non-space characters are allowed

Live Demo: http://www.rubular.com/r/x2MU1fbAhE

Problem

I want to allow anything and everything.. except blank entries (NULL, zero characters, whatever you want to call it) and also blank spaces of any length should not be allowed. This is essentially what I would do with a TRIM() function if I were coding in a language, but I have a need to do this with only regex. Thank you!

Original source