Jump to content

A regex which matches when != to something


Recommended Posts

I need a regular expression which will match ONLY when it doesn't match something.  For example I only don't want it to match when it was compared to the text "please select" and no match all other text.

 

In this case I am after the opposite of what the regular expression = Please select would match.  I'm after something like != Please select.

 

I hope you understand!!

Link to comment
https://forums.phpfreaks.com/topic/132155-a-regex-which-matches-when-to-something/
Share on other sites

Yes but it all has to be within the regex otherwise I would do a simple if(! ...).  This is becuase it is part of a validation control in an asp.net application (yes I know its a bit cheeky asking on here but you guys know your regexes!).  I need the regex to match (revert to true) when it doesn't match a given value.

Not that I know of as the asp validation is meant to check that a peice of input is correct.  For example if something matches an e-mail address it is considered valid - that is when it matches the regex the input is valid.  However I'm trying to check that a user selected something from a drop-down box - hence this time if the regex matches "please select" i need to be returned as invalid.

Since your question is ASP related, I would point you to this community instead, as it is not strictly PHP based. There are ASP users there who would be able to help you.

 

Principally, Effigy is right in both his suggestions.. just a matter of implementing it using ASP syntax.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.