views:

103

answers:

3

I need a Regular Expression for "Atleast 6 characters with no spaces"
Please help

+4  A: 
  • To allow anything other than whitespace ^\S{6,}$
  • To allow only alphabets: ^[a-zA-Z]{6,}$
  • To allow word chars (alphanumeric and _): ^\w{6,}$
Amarghosh
A: 

You can use \w{6,}

Also FYI:

you can use Regex Coach for Regular Expression experiments. It is easy to play with Regular Expressions by using tools like Regex Coach.

Upul
A: 

For literally any six non-space characters (other than newlines, depending on options):

[^ ]{6,}

For six non-whitespace characters:

\S{6,}
Jesse Millikan
In both cases it should be {6,} since vaibhav states "at least 6 characters"
Bernhof