golfwebuk Posted April 12, 2010 Share Posted April 12, 2010 Hi Guys! I have created a search form in PHP and the user has the ability to select "Exclude hyphens" and "Exclude numbers" from search options. When they select Exlude hyphens for example, the search should return only rows that DO NOT contain hyphens. The same applies for numbers. I am trying something like this, but to no avail. select * from domains where domain NOT LIKE '^[0-9]+$' Please help Quote Link to comment https://forums.phpfreaks.com/topic/198284-regex-help-needed-with-mysql/ Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 Try REGEXP - http://dev.mysql.com/doc/refman/5.1/en/regexp.html Quote Link to comment https://forums.phpfreaks.com/topic/198284-regex-help-needed-with-mysql/#findComment-1040425 Share on other sites More sharing options...
golfwebuk Posted April 12, 2010 Author Share Posted April 12, 2010 Try REGEXP - http://dev.mysql.com/doc/refman/5.1/en/regexp.html Thanks, but I have also tried the following to no avail. select * from domains where domain NOT REGEX '^[0-9]+$' Quote Link to comment https://forums.phpfreaks.com/topic/198284-regex-help-needed-with-mysql/#findComment-1040496 Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 It's REGEXP, not REGEX. Your regexp doesn't do what you want. You wanted a regexp that returns results that doesn't match it. Your regexp is for a string of numbers and numbers only. SELECT * FROM domains WHERE domain REGEXP '[^0-9]'; Quote Link to comment https://forums.phpfreaks.com/topic/198284-regex-help-needed-with-mysql/#findComment-1040515 Share on other sites More sharing options...
golfwebuk Posted April 12, 2010 Author Share Posted April 12, 2010 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/198284-regex-help-needed-with-mysql/#findComment-1040516 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.