Skip to content
Merged
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
60 changes: 54 additions & 6 deletions docs/UserGuide/Operators-Functions/String.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,60 @@ select s1, substring(s1 from 1 for 2) from root.sg1.d1
Output series:

```
+-----------------------------+--------------+----------------------------------------------+
| Time|root.sg1.d1.s1|SUBSTRING(root.sg1.d1.s1 FROM 1 FOR 2) |
+-----------------------------+--------------+----------------------------------------------+
|1970-01-01T08:00:00.001+08:00| 1test1| 1t|
|1970-01-01T08:00:00.002+08:00| 22test22| 22|
+-----------------------------+--------------+----------------------------------------------+
+-----------------------------+--------------+--------------------------------------+
| Time|root.sg1.d1.s1|SUBSTRING(root.sg1.d1.s1 FROM 1 FOR 2)|
+-----------------------------+--------------+--------------------------------------+
|1970-01-01T08:00:00.001+08:00| 1test1| 1t|
|1970-01-01T08:00:00.002+08:00| 22test22| 22|
+-----------------------------+--------------+--------------------------------------+
```

## replace

### Usage

Replace a substring in the input sequence with the target substring.

**Name:** REPLACE

**Input Series:** Only support a single input series. The data type is TEXT.

**Parameter:**
+ first parameter: The target substring to be replaced.
+ second parameter: The substring to replace with.

**Output Series:** Output a single series. The type is TEXT.

**Note:** Returns NULL if input is NULL.

### Examples

Input series:

```
+-----------------------------+--------------+
| Time|root.sg1.d1.s1|
+-----------------------------+--------------+
|1970-01-01T08:00:00.001+08:00| 1test1|
|1970-01-01T08:00:00.002+08:00| 22test22|
+-----------------------------+--------------+
```

SQL for query:

```sql
select s1, replace(s1, 'es', 'tt') from root.sg1.d1
```

Output series:

```
+-----------------------------+--------------+-----------------------------------+
| Time|root.sg1.d1.s1|REPLACE(root.sg1.d1.s1, 'es', 'tt')|
+-----------------------------+--------------+-----------------------------------+
|1970-01-01T08:00:00.001+08:00| 1test1| 1tttt1|
|1970-01-01T08:00:00.002+08:00| 22test22| 22tttt22|
+-----------------------------+--------------+-----------------------------------+
```

## Upper
Expand Down
1 change: 1 addition & 0 deletions docs/zh/UserGuide/Operators-Functions/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ OR, |, ||
| ENDSWITH | TEXT | `target`: 需要匹配的后缀 | BOOLEAN | 判断字符串是否有指定后缀 |
| CONCAT | TEXT | `targets`: 一系列 K-V, key需要以`target`为前缀且不重复, value是待拼接的字符串。<br/>`series_behind`: 指定拼接时时间序列是否在后面,默认为`false`。 | TEXT | 拼接字符串和`target`字串 |
| SUBSTRING | TEXT | `from`: 指定子串开始下标 <br/>`for`: 指定的字符个数之后停止 | TEXT | 提取字符串的子字符串,从指定的第一个字符开始,并在指定的字符数之后停止。下标从1开始。from 和 for的范围是 INT32 类型取值范围。 |
| REPLACE | TEXT | 第一个参数: 需要替换的目标子串<br />第二个参数:要替换成的子串 | TEXT | 将输入序列中的子串替换成目标子串 |
| UPPER | TEXT | 无 | TEXT | 将字符串转化为大写 |
| LOWER | TEXT | 无 | TEXT | 将字符串转化为小写 |
| TRIM | TEXT | 无 | TEXT | 移除字符串前后的空格 |
Expand Down
68 changes: 58 additions & 10 deletions docs/zh/UserGuide/Operators-Functions/String.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,60 @@ select s1, substring(s1 from 1 for 2) from root.sg1.d1
输出序列:

```
+-----------------------------+--------------+----------------------------------------------+
| Time|root.sg1.d1.s1| SUBSTRING(root.sg1.d1.s1 FROM 1 FOR 2) |
+-----------------------------+--------------+----------------------------------------------+
|1970-01-01T08:00:00.001+08:00| 1test1| 1t|
|1970-01-01T08:00:00.002+08:00| 22test22| 22|
+-----------------------------+--------------+----------------------------------------------+
+-----------------------------+--------------+--------------------------------------+
| Time|root.sg1.d1.s1|SUBSTRING(root.sg1.d1.s1 FROM 1 FOR 2)|
+-----------------------------+--------------+--------------------------------------+
|1970-01-01T08:00:00.001+08:00| 1test1| 1t|
|1970-01-01T08:00:00.002+08:00| 22test22| 22|
+-----------------------------+--------------+--------------------------------------+
```

### Replace

#### 函数简介
将输入序列中的子串替换成目标子串。

**函数名:** REPLACE


**输入序列:** 仅支持单个输入序列,类型为TEXT。

**参数:**
+ 第一个参数: 需要替换的目标子串。
+ 第二个参数: 要替换成的子串。

**输出序列:** 输出单个序列,类型为 TEXT。

**提示:** 如果输入是NULL,返回NULL。

#### 使用示例

输入序列:

```
+-----------------------------+--------------+
| Time|root.sg1.d1.s1|
+-----------------------------+--------------+
|1970-01-01T08:00:00.001+08:00| 1test1|
|1970-01-01T08:00:00.002+08:00| 22test22|
+-----------------------------+--------------+
```

用于查询的 SQL 语句:

```sql
select s1, replace(s1, 'es', 'tt') from root.sg1.d1
```

输出序列:

```
+-----------------------------+--------------+-----------------------------------+
| Time|root.sg1.d1.s1|REPLACE(root.sg1.d1.s1, 'es', 'tt')|
+-----------------------------+--------------+-----------------------------------+
|1970-01-01T08:00:00.001+08:00| 1test1| 1tttt1|
|1970-01-01T08:00:00.002+08:00| 22test22| 22tttt22|
+-----------------------------+--------------+-----------------------------------+
```

### Upper
Expand Down Expand Up @@ -591,7 +639,7 @@ select s1, s2, strcmp(s1, s2) from root.sg1.d1

#### 函数简介

**非内置函数,需要注册数据质量函数库后才能使用。**本函数用于将文本中的子串替换为指定的字符串。
**非内置函数,需要注册数据质量函数库后才能使用**。本函数用于将文本中的子串替换为指定的字符串。

**函数名:** STRREPLACE

Expand Down Expand Up @@ -669,7 +717,7 @@ select strreplace(s1, "target"=",", "replace"="/", "limit"="1", "offset"="1", "r

#### 函数简介

**非内置函数,需要注册数据质量函数库后才能使用。**本函数用于正则表达式匹配文本中的具体内容并返回。
**非内置函数,需要注册数据质量函数库后才能使用**。本函数用于正则表达式匹配文本中的具体内容并返回。

**函数名:** REGEXMATCH

Expand Down Expand Up @@ -726,7 +774,7 @@ select regexmatch(s1, "regex"="\d+\.\d+\.\d+\.\d+", "group"="0") from root.test.

#### 函数简介

**非内置函数,需要注册数据质量函数库后才能使用。**本函数用于将文本中符合正则表达式的匹配结果替换为指定的字符串。
**非内置函数,需要注册数据质量函数库后才能使用**。本函数用于将文本中符合正则表达式的匹配结果替换为指定的字符串。

**函数名:** REGEXREPLACE

Expand Down Expand Up @@ -784,7 +832,7 @@ select regexreplace(s1, "regex"="192\.168\.0\.(\d+)", "replace"="cluster-$1", "l

#### 函数简介

**非内置函数,需要注册数据质量函数库后才能使用。**本函数用于使用给定的正则表达式切分文本,并返回指定的项。
**非内置函数,需要注册数据质量函数库后才能使用**。本函数用于使用给定的正则表达式切分文本,并返回指定的项。

**函数名:** REGEXSPLIT

Expand Down