Skip to content

[doc](fucntion) add some doc about regexp_replace flag #2441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Regular matching of STR strings, replacing the part hitting pattern with a new s
## Syntax

```sql
REGEXP_REPLACE(<str>, <pattern>, <repl>)
REGEXP_REPLACE(<str>, <pattern>, <repl>, [flag])
```

## Parameters
Expand All @@ -43,6 +43,7 @@ REGEXP_REPLACE(<str>, <pattern>, <repl>)
| `<str>` | The column need to do regular matching.|
| `<pattern>` | Target pattern.|
| `<repl>` | The string to replace the matched pattern.|
| [flag] | Optional parameter used to specify whether to allow ignoring invalid escape characters. For example, `\{` is equivalent to `{` |

## Return Value

Expand Down Expand Up @@ -71,4 +72,18 @@ mysql> select regexp_replace('这是一段中文 This is a passage in English 12
+---------------------------------------------------------------------------------------------+
| 123This is a passage in English 1234567 |
+---------------------------------------------------------------------------------------------+

mysql> select regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{');
+-----------------------------------------------------------------+
| regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{') |
+-----------------------------------------------------------------+
| {"abc":5"def":78} |
+-----------------------------------------------------------------+

mysql> select regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{', 'IGNORE_INVALID_ESCAPE');
+------------------------------------------------------------------------------------------+
| regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{', 'IGNORE_INVALID_ESCAPE') |
+------------------------------------------------------------------------------------------+
| {"abc":5}&&{"def":78} |
+------------------------------------------------------------------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ under the License.
## 语法

```sql
REGEXP_REPLACE(<str>, <pattern>, <repl>)
REGEXP_REPLACE(<str>, <pattern>, <repl>, [flag])
```

## 参数
Expand All @@ -43,6 +43,7 @@ REGEXP_REPLACE(<str>, <pattern>, <repl>)
| `<str>` | 需要进行正则匹配的列。|
| `<pattern>` | 目标模式。|
| `<repl>` | 用于替换匹配模式的字符串。|
| `[flag]`| 可选参数,用于设置是否允许忽略不合法的转义字符。例如 `\{` 等价于 `{`|

## 返回值

Expand Down Expand Up @@ -71,3 +72,18 @@ mysql> select regexp_replace('这是一段中文 This is a passage in English 12
+---------------------------------------------------------------------------------------------+
| 123This is a passage in English 1234567 |
+---------------------------------------------------------------------------------------------+

mysql> select regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{');
+-----------------------------------------------------------------+
| regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{') |
+-----------------------------------------------------------------+
| {"abc":5"def":78} |
+-----------------------------------------------------------------+

mysql> select regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{', 'IGNORE_INVALID_ESCAPE');
+------------------------------------------------------------------------------------------+
| regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{', 'IGNORE_INVALID_ESCAPE') |
+------------------------------------------------------------------------------------------+
| {"abc":5}&&{"def":78} |
+------------------------------------------------------------------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ under the License.
## 语法

```sql
REGEXP_REPLACE(<str>, <pattern>, <repl>)
REGEXP_REPLACE(<str>, <pattern>, <repl>, [flag])
```

## 参数
Expand All @@ -43,6 +43,7 @@ REGEXP_REPLACE(<str>, <pattern>, <repl>)
| `<str>` | 需要进行正则匹配的列。|
| `<pattern>` | 目标模式。|
| `<repl>` | 用于替换匹配模式的字符串。|
| `[flag]`| 可选参数,用于设置是否允许忽略不合法的转义字符。例如 `\{` 等价于 `{`。3.0.7版本开始支持|

## 返回值

Expand Down Expand Up @@ -71,3 +72,18 @@ mysql> select regexp_replace('这是一段中文 This is a passage in English 12
+---------------------------------------------------------------------------------------------+
| 123This is a passage in English 1234567 |
+---------------------------------------------------------------------------------------------+

mysql> select regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{');
+-----------------------------------------------------------------+
| regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{') |
+-----------------------------------------------------------------+
| {"abc":5"def":78} |
+-----------------------------------------------------------------+

mysql> select regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{', 'IGNORE_INVALID_ESCAPE');
+------------------------------------------------------------------------------------------+
| regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{', 'IGNORE_INVALID_ESCAPE') |
+------------------------------------------------------------------------------------------+
| {"abc":5}&&{"def":78} |
+------------------------------------------------------------------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Regular matching of STR strings, replacing the part hitting pattern with a new s
## Syntax

```sql
REGEXP_REPLACE(<str>, <pattern>, <repl>)
REGEXP_REPLACE(<str>, <pattern>, <repl>, [flag])
```

## Parameters
Expand All @@ -43,6 +43,7 @@ REGEXP_REPLACE(<str>, <pattern>, <repl>)
| `<str>` | The column need to do regular matching.|
| `<pattern>` | Target pattern.|
| `<repl>` | The string to replace the matched pattern.|
| [flag] | Optional parameter used to specify whether to allow ignoring invalid escape characters. For example, `\{` is equivalent to `{`. since 3.0.7 version supported |

## Return Value

Expand Down Expand Up @@ -71,4 +72,18 @@ mysql> select regexp_replace('这是一段中文 This is a passage in English 12
+---------------------------------------------------------------------------------------------+
| 123This is a passage in English 1234567 |
+---------------------------------------------------------------------------------------------+

mysql> select regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{');
+-----------------------------------------------------------------+
| regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{') |
+-----------------------------------------------------------------+
| {"abc":5"def":78} |
+-----------------------------------------------------------------+

mysql> select regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{', 'IGNORE_INVALID_ESCAPE');
+------------------------------------------------------------------------------------------+
| regexp_replace('{"abc":5},{"def":78}', '\\}\\,\\{', '\\}&&\\{', 'IGNORE_INVALID_ESCAPE') |
+------------------------------------------------------------------------------------------+
| {"abc":5}&&{"def":78} |
+------------------------------------------------------------------------------------------+
```