imperium2335 Posted May 18, 2011 Share Posted May 18, 2011 Hi, How can I make this work? $partRe = mysql_query("SELECT partNumber FROM parts_table WHERE partNumber LIKE '%$queryCleaned%' REGEXP '[^A-Za-z0-9]' LIMIT 5") Quote Link to comment https://forums.phpfreaks.com/topic/236757-regexp-help/ Share on other sites More sharing options...
Pikachu2000 Posted May 18, 2011 Share Posted May 18, 2011 What are you trying to make it do? Quote Link to comment https://forums.phpfreaks.com/topic/236757-regexp-help/#findComment-1217041 Share on other sites More sharing options...
imperium2335 Posted May 18, 2011 Author Share Posted May 18, 2011 In the base there are part numbers like this aaaa,bbbb,cccc. But, sometimes there may be part numbers like this a-aaa, a-a-a-a etc. I want it to bring out results for comparison to a cleaned string from user input, so even if someone put in A-12-YU, in the database it may be stored as A12YU, but I would want it to bring back a match. Quote Link to comment https://forums.phpfreaks.com/topic/236757-regexp-help/#findComment-1217043 Share on other sites More sharing options...
Maq Posted May 18, 2011 Share Posted May 18, 2011 To clarify, the database values DO NOT contain dashes? But if the user enters a code with dashes you want them to match anyway? If the above is correct then strip out the slashes in PHP and then compare to the DB. Quote Link to comment https://forums.phpfreaks.com/topic/236757-regexp-help/#findComment-1217052 Share on other sites More sharing options...
imperium2335 Posted May 18, 2011 Author Share Posted May 18, 2011 Hi, database values may contain slashes and chars other than letters and numbers. Quote Link to comment https://forums.phpfreaks.com/topic/236757-regexp-help/#findComment-1217066 Share on other sites More sharing options...
imperium2335 Posted May 19, 2011 Author Share Posted May 19, 2011 Any ideas? :/ Quote Link to comment https://forums.phpfreaks.com/topic/236757-regexp-help/#findComment-1217390 Share on other sites More sharing options...
imperium2335 Posted May 19, 2011 Author Share Posted May 19, 2011 After reading I don't think it is possible, so what I've done is create a new column with all things but numbers and letters stripped out. This should speed things up anyway when searching that column right? Quote Link to comment https://forums.phpfreaks.com/topic/236757-regexp-help/#findComment-1217522 Share on other sites More sharing options...
fenway Posted May 20, 2011 Share Posted May 20, 2011 You simply need to strip both values when you compare them. Quote Link to comment https://forums.phpfreaks.com/topic/236757-regexp-help/#findComment-1218154 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.