Past the example coordinating accessible from LIKE provisos, MariaDB offers ordinary articulation based coordinating through the REGEXP administrator. The administrator performs design coordinating for a string articulation dependent on a given example.
MariaDB 10.0.5 presented PCRE Regular Expressions, which significantly expands the extent of coordinating into territories like recursive examples, look-ahead attestations, and that's only the tip of the iceberg.
Audit the utilization of standard REGEXP administrator language structure given beneath −
SELECT column FROM table_name WHERE column REGEXP '[PATTERN]';
REGEXP returns 1 for an example match or 0 without one.
A possibility for the contrary exists as NOT REGEXP. MariaDB likewise offers equivalent words for REGEXP and NOT REGEXP, RLIKE and NOT RLIKE, which were made for similarity reasons.
The example looked at can be an exacting string or something different, for example, a table segment. In strings, it utilizes C departure language structure, so twofold any "\" characters. REGEXP is likewise case-harsh, except for paired strings.
A table of potential examples, which can be utilized are given underneath −
Sr.No | Pattern & Description |
---|---|
1 |
^ It matches the start of the string. |
2 |
$ It matches the string's end. |
3 |
. It matches a single character. |
4 |
[...] It matches any character in the brackets. |
5 |
[^...] It matches any character not listed in the brackets. |
6 |
p1|p2|p3 It matches any of the patterns. |
7 |
* It matches 0 or more instances of the preceding element. |
8 |
+ It matches 1 or more instances of the preceding element. |
9 |
{n} It matches n instances of the preceding element. |
10 |
{m,n} It matches m to n instances of the preceding element. |
Survey the example coordinating models given beneath −
Items beginning with "pr" −
SELECT name FROM product_tbl WHERE name REGEXP '^pr';
Items finishing with "na" −
SELECT name FROM product_tbl WHERE name REGEXP 'na$';
Items beginning with a vowel −
SELECT name FROM product_tbl WHERE name REGEXP '^[aeiou]';
