MySQL RLIKE Operator

In MySQL, The RLIKE operator returns whether a string matches a regular expression.

RLIKE is the same as REGEXP.

RLIKE Syntax

Here is the syntax of the MySQL RLIKE operator:

str RLIKE regexp

Parameters

str
Required. The string to be tested.
regexp
Required. The regular expression to which the string str is to be matched.

Return value

RLIKE returns 1 if the string str matches the gaven regular expression regexp, otherwise it returns 0.

If any parameter is NULL, RLIKE returns NULL.

RLIKE performs a Case-insensitive matching.

RLIKE Examples

Here are some examples of MySQL CHAR() function.

SELECT
    'hello' RLIKE '^[a-z]+$',
    'hello' RLIKE '^[A-Z]+$',
    '12345' RLIKE '[0-9]+$',
    '12345' RLIKE '^\\d+$',
    '123ab' RLIKE '^\\d*$',
    '123ab' RLIKE '^.*$'\G
'hello' RLIKE '^[a-z]+$': 0
'hello' RLIKE '^[A-Z]+$': 0
 '12345' RLIKE '[0-9]+$': 0
  '12345' RLIKE '^\\d+$': 0
  '123ab' RLIKE '^\\d*$': 1
    '123ab' RLIKE '^.*$': 0