content_image/853345.jpg
Repetition; { n }  and { m , n }  notation provide a more general way of writing regular expressions that match many occurrences of the previous atom (or “piece” ) of the pattern. m  and n  are integers. 

• a* 

Can be written as a{0,} . 

• a+ 

Can be written as a{1,} . 

• a? 

Can be written as a{0,1} . 

To be more precise, a{ n }  matches exactly n  instances of a . a{ n ,}  matches n  or more instances of a . a{ m , n }  matches m  through n  instances of a , inclusive. If both m  and n  are given, m  must be less than or equal to n . 

mysql> SELECT REGEXP_LIKE(’abcde’, ’a[bcd]{2}e’); -> 0 mysql> SELECT REGEXP_LIKE(’abcde’, ’a[bcd]{3}e’); -> 1 mysql> SELECT REGEXP_LIKE(’abcde’, ’a[bcd]{1,10}e’); -> 1 

• [a-dX] , [^a-dX] 

Matches any character that is (or is not, if ^  is used) either a , b , c , d  or X . A -  character between two other characters forms a range that matches all characters from the first character to the second. For example, [0-9]  matches any decimal digit. To include a literal ]  character, it must immediately follow the opening bracket [ . To include a literal -  character, it must be written first or last. Any character that does not have a defined special meaning inside a []  pair matches only itself. 

mysql> SELECT REGEXP_LIKE(’aXbc’, ’[a-dXYZ]’); -> 1 mysql> SELECT REGEXP_LIKE(’aXbc’, ’^[a-dXYZ]$’); -> 0 mysql> SELECT REGEXP_LIKE(’aXbc’, ’^[a-dXYZ]+$’); -> 1 mysql> SELECT REGEXP_LIKE(’aXbc’, ’^[^a-dXYZ]+$’); -> 0 mysql> SELECT REGEXP_LIKE(’gheis’, ’^[^a-dXYZ]+$’); -> 1 mysql> SELECT REGEXP_LIKE(’gheisa’, ’^[^a-dXYZ]+$’); -> 0 

• [=character_class=] 

Within a bracket expression (written using [  and ] ), [=character_class=]  represents an equivalence class. It matches all characters with the same collation value, including itself. For example, if o  and (+)  are the members of an equivalence class, [[=o=]] , [[=(+)=]] , and [o(+)]  are all synonymous. An equivalence class may not be used as an endpoint of a range. 

• [:character_class:] 

Within a bracket expression (written using [  and ] ), [:character_class:]  represents a character class that matches all characters belonging to that class. The following table lists the standard class names. These names stand for the character classes defined in the ctype(3)  manual page. A particular locale may provide other class names. A character class may not be used as an endpoint of a range. 

<img src='content_image/853345.jpg'>

