In MariaDB, the REGEXP
operator is used to determine whether or not a string matches a regular expression.
If the string matches the regular expression provided, the result is 1
, otherwise it’s 0
.
In MariaDB, the REGEXP
operator is used to determine whether or not a string matches a regular expression.
If the string matches the regular expression provided, the result is 1
, otherwise it’s 0
.
MySQL has a number of functions and operators that allow us to perform operations using regular expressions (regex). This article presents two operators and one function that enable us to find out if a string matches a regular expression specified by a given pattern.
These regex functions and operators are:
These are all basically equivalent, as the operators (the second two) are both synonyms of the function (the first one). In any case, you can see examples of all three in action below.
In MySQL, the REGEXP_REPLACE()
function replaces occurrences of the substring within a string that matches the given regular expression pattern.
The whole string is returned along with the replacements.
If there’s no match (i.e. the input string doesn’t contain the substring), the the whole string is returned unchanged.
In MySQL, the REGEXP_INSTR()
function returns the starting index of a substring that matches the regular expression pattern.
The index starts at 1
. If there’s no match, the result is 0
.
In MySQL, the REGEXP_SUBSTR()
function returns the substring that matches the given regular expression pattern.
If there’s no match (i.e. the input string doesn’t contain the substring), the result is NULL
.
In MySQL, the RLIKE
operator is used to determine whether or not a string matches a regular expression. It’s a synonym for REGEXP_LIKE()
.
If the string matches the regular expression provided, the result is 1
, otherwise it’s 0
.
In MySQL, the REGEXP
operator is used to determine whether or not a string matches a regular expression. It’s a synonym for REGEXP_LIKE()
.
If the string matches the regular expression provided, the result is 1
, otherwise it’s 0
.
In MySQL, the REGEXP_LIKE()
function is used to determine whether or not a string matches a regular expression.
The function returns 1
if the string matches the regular expression provided, and 0
if it doesn’t.