📜  MariaDB正则表达式

📅  最后修改于: 2020-11-29 05:59:52             🧑  作者: Mango

MariaDB正则表达式

MariaDB通过REGEXP运算符提供基于正则表达式的匹配。

句法:

expression REGEXP pattern

参数说明:

expression:字符表达式,例如列或字段。

pattern:正则表达式匹配信息。模式可以是以下各项的组合:

Value Description
^ 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.
\n n 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.
\d Matches a digit character.
\d Matches a non-digit character.
\w Matches a word character.
\w Matches a non-word character.
\s Matches a whitespace character.
\s Matches 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.