Characters and classes used by the REGEXP and NOT REGEXP operators (or RLIKE and NOT RLIKE, which are synonyms) : REGEXP « Regular Expressions « MySQL Tutorial






'.' matches any single character.

A character class '[...]' matches any character within the brackets.

For example, '[abc]' matches 'a', 'b', or 'c'.

To name a range of characters, use a dash.

'[a-z]' matches any letter, whereas '[0-9]' matches any digit.

'*' matches zero or more instances of the thing preceding it.

For example, 'x*' matches any number of 'x' characters.

'[0-9]*' matches any number of digits.

'.*' matches any number of anything.

A REGEXP pattern match succeeds if the pattern matches anywhere in the value being tested.

A LIKE pattern match succeeds only if the pattern matches the entire value.

'^' matches the beginning of the pattern.

'$' matches the end of the pattern.









24.10.REGEXP
24.10.1.Characters and classes used by the REGEXP and NOT REGEXP operators (or RLIKE and NOT RLIKE, which are synonyms)
24.10.2.To find names beginning with 'J', use '^' to match the beginning of the name
24.10.3.To matches only lowercase 'b' at the beginning of a name
24.10.4.To find names ending with 'es', use '$' to match the end of the name
24.10.5.To find names containing an 'e', use this query
24.10.6.To find names containing exactly five characters
24.10.7.To find names containing exactly five characters using {n}
24.10.8.SELECT '1+2' REGEXP '1\\+2';
24.10.9.REGEXP '^[a-f]'
24.10.10.REGEXP '^[mn].*[sz]$'