java - Regular Expression - Should not allow whitespaces continuously -


In my web application, I have a text box where the user should enter between 5 and 200 characters.

The problem is - when the user continually takes 5 spaces and saves the entry, then it is successfully saving it

I constantly use the 'Whitespace' user (or white alone Place) should be blocked to enter.

But I can allow single whitespace (like 'customer table', customer table ').

But I can allow the user to enter white space with characters. Also, I do not want to start the place by name.

Can anyone help me in getting the REEG for the above condition?

^ \ S + (\ s \ S +) * $ < / P>

this should you do regexp. It accepts an empty blank string and ends with non-whitespace characters, and with only a single white space between words.

You should check the length of the total string separately.

Note that you need to avoid \ Java.

Comments