Jump to content

MySQl RegEx


loll

Recommended Posts

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/45629-mysql-regex/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.