^(.)+\S{10}(.)+$
I have that regex which will match any string that contains a word of 10 characters.
However I need the INVERSE of that.
A regex that will only match strings which do NOT have words of >=10 characters.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use negative assertion.
\S{10}matches a sequence of 10\S(which must be a subsequence of anything longer).(?!pattern)is a negative lookahead, an assertion that is true if the pattern doesn’t match..*allows the lookahead to look as far as necessary.The whole pattern therefore is
This matches all string that do NOT contain
\S{10}.See also