MySQL 정규표현 함수
MySQL5.7 에서는 아래와 같은 함수를 지원한다.
NOT REGEXP : Negation of REGEXP
REGEXP : Whether string matches regular expression
RLIKE : Whether string matches regular expression
자세한 내용은 MySQL 홈페이지를 참조한다.
https://dev.mysql.com/doc/refman/5.7/en/regexp.html
MySQL :: MySQL 5.7 Reference Manual :: 12.7.2 Regular Expressions
12.7.2 Regular Expressions Table 12.13 Regular Expression Functions and Operators Name Description NOT REGEXP Negation of REGEXP REGEXP Whether string matches regular expression RLIKE Whether string matches regular expression A regular expression is a powe
dev.mysql.com
MySQL 8.0에서는 아래와 같은 함수를 지원한다.
NOT REGEXP : Negation of REGEXP
REGEXP : Whether string matches regular expression
REGEXP_INSTR() : Starting index of substring matching regular expression
REGEXP_LIKE : Whether string matches regular expression
REGEXP_REPLACE() : Replace substrings matching regular expression
REGEXP_SUBSTR() : Return substring matching regular expression
RLIKE : Whether string matches regular expression
* REGEXP and RLIKE are synonyms for REGEXP_LIKE().
자세한 내용은 MySQL 홈페이지를 참조한다.
https://dev.mysql.com/doc/refman/8.0/en/regexp.html
MySQL :: MySQL 8.0 Reference Manual :: 12.7.2 Regular Expressions
12.7.2 Regular Expressions Table 12.13 Regular Expression Functions and Operators Name Description NOT REGEXP Negation of REGEXP REGEXP Whether string matches regular expression REGEXP_INSTR() Starting index of substring matching regular expression REGEXP_
dev.mysql.com
*expr : expression
*pat : pattern
1. NOT REGEXP, REGEXP, RLIKE, REGEXP_LIKE();
- expr NOT REGEXP pat, expr NOT RLIKE pat(This is the same as NOT (expr REGEXP pat))
- expr REGEXP pat, expr RLIKE pat
RETURN 값은 1, 0, NULL 이다.
1 : 값이 일치
0 : 값이 일치하지 않을 경우
NULL : expr 또는 pat 이 NULL일 경우
2. REGEXP_INSTR()
- 문자열이 처음으로 나오는 index 를 return, 0을 return 하면 매칭 되는 것이 없는 것, expr 또는 pat 이 NULL일 경우 NULL을 return
mysql> SELECT REGEXP_INSTR('dog cat dog', 'dog');
+------------------------------------+
| REGEXP_INSTR('dog cat dog', 'dog') |
+------------------------------------+
| 1 |
+------------------------------------+
.....