Regular Expressions in MariaDB

MariaDB Regular Expressions
Regular expression-based matching is possible in MariaDB through the REGEXP Operator.

Syntax:

expression REGEXP pattern

 

Parameters:

expression: It is used to specify a character expression such as a column or field.

pattern: It is used to specify the regular expression matching information. The value of the pattern can be:

 

VALUE USES
^ To match the beginning of a string.
$ To match the end of a string.
* To match zero or more occurrences.
+ To match one or more occurrences.
? To match zero or one occurrence.
. To match any character except null.
| To specify more than one alternative.
[ ] To specify a matching list to match any one of the characters in the list.
[^ ] To specify a non matching list to match any character except for the ones in the list.
( ) To group expressions as a subexpression.
{m} To match m times.
{m,} To match at least m times.
{m,n} To match at least m times, but no more than n times.
\n To match the nth subexpression found within ( ) before encountering \n, where n is a number between 1 and 9.
[..] To match one collation element that can be more than one character.
[::] To match character classes.
[==] To match equivalence classes.
\d To match a digit character.
\d To match a non-digit character.
\w To match a word character.
\w To match a non-word character.
\s To match a whitespace character.
\s To match a non-whitespace character.
*? To match the preceding pattern zero or more occurrences.
+? To match the preceding pattern one or more occurrences.
?? To match the preceding pattern zero or one occurrence.
{n}? To match the preceding pattern n times.
{n,}? To match the preceding pattern at least n times.
{n,m}? To match the preceding pattern at least n times, but not more than m times.