loll Posted April 4, 2007 Share Posted April 4, 2007 Hi, I am trying to figure out a mysql regex and its not giving me the results I expect, So I amobviously doing something wrong I have a dictionary listing in a mysql table. I started the regex by using this sql statement: SELECT * FROM `dictionary` WHERE word_list REGEXP '[tes]' AND word_list NOT REGEXP '[abcdfghijklmnopqruvwxyz]' This was ok except it was giving results where there was any number of t's E's or S's so I changed it to: SELECT * FROM `dictionary` WHERE word_list REGEXP '[t{0,2}e{0,1}s{0,1}]' AND word_list NOT REGEXP '[abcdfghijklmnopqruvwxyz]' What I am trying to acheive is for it to give me words like TEST SET ET etc. but not show words like SEE TEES etc because those have too many S's and E's etc. I thought by adding the {0,1} etc next to the letters that that would limit the number of S's it was looking for to either none or 1 at most. Any Help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/45629-mysql-regex/ Share on other sites More sharing options...
Wildbug Posted April 4, 2007 Share Posted April 4, 2007 The one-shot regexp probably won't work or be very efficient. You could try splitting it up, though. SELECT * FROM dictionary WHERE word_list NOT REGEXP 't.*t.*t' AND word_list NOT REGEXP 'e.*e*' AND word_list NOT REGEXP 's.*s'; Quote Link to comment https://forums.phpfreaks.com/topic/45629-mysql-regex/#findComment-221670 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.