2

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

2
  • Any restrictions what characters it should be? Anything that is not a space? Letters, numbers? Commented Jan 5, 2010 at 10:53
  • Yes any character except space. Commented Jan 5, 2010 at 10:56

3 Answers 3

4
  • To allow anything other than whitespace ^\S{6,}$
  • To allow only alphabets: ^[a-zA-Z]{6,}$
  • To allow word chars (alphanumeric and _): ^\w{6,}$
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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

[^ ]{6,}

For six non-whitespace characters:

\S{6,}

1 Comment

In both cases it should be {6,} since vaibhav states "at least 6 characters"

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.