Hi All,

I need to have a Regex that will not allow just spaces, but it can allow sentences with spaces. It should allow any special characters that occur as well.

Actually, it is for a text area of comments. So i want to restrict him from entering just spaces.

Well, i tried

1. ^[^\\s]*$
2. ^[a-zA-Z0-9^\\s]*$

If any variation of the second one works, i'm willing to type out the entire special characters set that is there in the keyboard.

Any help would be much appreciated.

Thanks,
Adarsh

If you want to eliminate an entry that is only spaces, then try this:

^[ ]*$

Thanks for the tip.

I used String.trim() to achieve the same. Silly mistake.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.