MariaDB Regular Expressions

MariaDB provides regular expression based matching through the REGEXP Operator.

Syntax:

Parameter Explanation:

expression: A character expression such as a column or field.

pattern: The regular expression matching information. A pattern can be a combination of the following:

ValueDescription
^Matches the beginning of a string. if used with a match_parameter of 'm', it matches the start of a line anywhere within expression.
$Matches the end of a string. if used with a match_parameter of 'm', it matches the end of a line anywhere within expression.
*Matches zero or more occurrences.
+Matches one or more occurrences.
?Matches zero or one occurrence.
.Matches any character except null.
|Used like an "or" to specify more than one alternative.
[ ]Used to specify a matching list where you are trying to match any one of the characters in the list.
[^ ]Used to specify a nonmatching list where you are trying to match any character except for the ones in the list.
( )Used to group expressions as a subexpression.
{m}Matches m times.
{m,}Matches at least m times.
{m,n}Matches at least m times, but no more than n times.
\nn is a number between 1 and 9. matches the nth subexpression found within ( ) before encountering \n.
[..]Matches one collation element that can be more than one character.
[::]Matches character classes.
[==]Matches equivalence classes.
\dMatches a digit character.
\dMatches a non-digit character.
\wMatches a word character.
\wMatches a non-word character.
\sMatches a whitespace character.
\sMatches a non-whitespace character.
*?Matches the preceding pattern zero or more occurrences.
+?Matches the preceding pattern one or more occurrences.
??Matches the preceding pattern zero or one occurrence.
{n}?Matches the preceding pattern n times.
{n,}?Matches the preceding pattern at least n times.
{n,m}?Matches the preceding pattern at least n times, but not more than m times.