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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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