> For the complete documentation index, see [llms.txt](https://learnsql.gitbook.io/lernmysql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learnsql.gitbook.io/lernmysql/welcome-to-the-mysql-tutorial/regular-expressions.md).

# Regular Expressions

| Name                                                                                              | Description                                                                                                          |
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| [`NOT REGEXP`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_not-regexp)           | Negation of REGEXP                                                                                                   |
| [`REGEXP`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp)                   | Whether string matches regular expression(Chuỗi có khớp với biểu thức chính quy không)                               |
| [`REGEXP_INSTR()`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-instr)     | Starting index of substring matching regular expression (Chỉ mục bắt đầu của chuỗi con khớp với biểu thức chính quy) |
| [`REGEXP_LIKE()`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-like)       | Whether string matches regular expression (Chuỗi có khớp với biểu thức chính quy không)                              |
| [`REGEXP_REPLACE()`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-replace) | Replace substrings matching regular expression (Thay thế các chuỗi khớp với biểu thức chính quy)                     |
| [`REGEXP_SUBSTR()`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-substr)   | Return substring matching regular expression (Trả về chuỗi con khớp với biểu thức chính quy)                         |
| [`RLIKE`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp)                    | Whether string matches regular expression (Chuỗi có khớp với biểu thức chính quy không)                              |

## Regexp trong MySQL

### Bảng dưới liệt kê các Pattern có thể được sử dụng cùng với toán tử **REGEXP**.

| Pattern    | So khớp với                                               |
| ---------- | --------------------------------------------------------- |
| ^          | Phần đầu của chuỗi                                        |
| $          | Phần cuối của chuỗi                                       |
| .          | Bất kỳ ký tự đơn nào                                      |
| \[...]     | Bất kỳ ký tự nào được liệt kê trong dấu ngoặc vuông       |
| \[^...]    | Bất kỳ ký tự nào không được liệt kê trong dấu ngoặc vuông |
| p1\|p2\|p3 | Bất kỳ mẫu p1, p2 hoặc p3 nào                             |
| \*         | 0 hoặc nhiều instance (sự thể hiện) của phần tử ở trước   |
| +          | 1 hoặc nhiều instance (sự thể hiện) của phần tử ở trước   |
| {n}        | n instance (sự thể hiện) của phần tử ở trước              |
| {m,n}      | Từ m tới n instance (sự thể hiện) của phần tử ở trước     |
