For those who haven't met the term before, a 'regular expression' is a "pattern", a set of rules for describing sequences of characters, pieces of text. Most of the characters are just as they would be in a 'literal' search - they only "mean" that particular character - but some of them are have special meanings. The simplest and most useful are :-
- . - dot, period, full-stop.
- This matches any single character at all. 'f.r' matches 'for' and 'farewell', but not 'fear' or 'from'
- ? - question-mark
- Matches 0 or 1 instance of the preceding character. 'f.?r' matches 'for', 'from', 'farewell', but not 'fear'.
- + - plus
- Matches 1 or more instances of the preceding character. 'f.+r' matches 'for', 'Fergus','fear', but not 'from'.
- * - star
- Matches 0 or more instances of the preceding character. 'f.*r' gets you everything mentioned above.
- | - vertical bar
- Alternatives - "match either of". search for 'red|f.*r' gets you everything in the previous example plus anything containing 'red' If you want to search for these, as literal characters, either a) use a literal search rather than a regular expression, or b) precede them with a '\' backslash character; eg, 'f\.\+r'
For those who have met the term before ... this is implemented here in MySQL, so the reference for the finer details would be the MySQL manual. (Translating the examples they give into the context of the text-field here, you'd write everything that follows the 'REGEXP' statement, without the enclosing quotes).