Possible Duplicate:
Regular expression to match string not containing a word?
How can I invert a regular expression in JavaScript?
Say I have the regex foo123. How do I match everything that is not foo123?
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 lookahead for this.
matches any string except
foo123If you want to match empty string also, use
(?!foo123).*In your case (according to the comment) the required regex is
(?!P[0-9]{1,}).+.It matches P and 123, but not P123.