23rd Jul, 2007

Regular Expressions

A regular expression is
a powerful way of specifying a pattern for a complex
search.

MySQL allows the following regular expression metacharacters:
. — match any character
? — match zero or one
* — match zero or more
+ — match one or more
{n} — match n times
{m,n} — match m through n times
{n,} — match n or more times
^ — beginning of line
$ — end of line
[[:<:]] — match beginning of words
[[:>:]] — match ending of words
[:class:] — match a character class
i.e., [:alpha:] for letters
[:space:] for whitespace
[:punct:] for punctuation
[:upper:] for upper case letters

[abc] — match one of enclosed chars
[^xyz] — match any char not enclosed
| — separates alternatives

Leave a response

Your response:

Categories and Tags

Advertising