I need a regular expression in MySQL that matches:
- a sentence that has a word
- that begins with e
- ends with k
- can contain [deki] (doesn’t have to include all)
- is 3-4 characters long
For example, the following would match:
- “My name is eik“
- “the edik of doom”
- “herp derp eidk derp”
MySQL’s extended regular expressions are pretty powerful; see http://dev.mysql.com/doc/refman/5.6/en/regexp.html. You can write:
(boundary-at-start-of-word, plus
e, plus one or two characters from[deki], plusk, plus boundary-at-end-of-word).This assumes that your words are separated by punctuation or spaces or whatnot, and it doesn’t require that your field contain multiple words.
(Hat-tip to Bohemian for giving an answer that used
\b. MySQL doesn’t support\bfor word-boundaries, but it reminded me of things my original answer missed.)