eddy556 Posted November 10, 2008 Share Posted November 10, 2008 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!! Quote Link to comment Share on other sites More sharing options...
effigy Posted November 10, 2008 Share Posted November 10, 2008 Like this? if ( ! preg_match(...) ) { ... } Do you even need a regex? Quote Link to comment Share on other sites More sharing options...
eddy556 Posted November 10, 2008 Author Share Posted November 10, 2008 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. Quote Link to comment Share on other sites More sharing options...
effigy Posted November 10, 2008 Share Posted November 10, 2008 You cannot work around these limitations? Try /(?!please select)/. Quote Link to comment Share on other sites More sharing options...
eddy556 Posted November 10, 2008 Author Share Posted November 10, 2008 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. Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted November 10, 2008 Share Posted November 10, 2008 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. Quote Link to comment Share on other sites More sharing options...
eddy556 Posted November 10, 2008 Author Share Posted November 10, 2008 okay many thanks for your answers! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.