From b3f02955d3b06352c59ec53eb95367afced108d1 Mon Sep 17 00:00:00 2001 From: zhoubintao <35688959+zbtzbtzbt@users.noreply.github.com> Date: Thu, 9 Sep 2021 14:11:37 +0800 Subject: [PATCH] [Doc] modify irregular documents (like/ not like/ regexp.md) (#6572) --- .../string-functions/like/like.md | 28 +++++++++++++---- .../string-functions/like/not_like.md | 31 ++++++++++++++----- .../string-functions/regexp/not_regexp.md | 2 +- .../string-functions/regexp/regexp.md | 2 +- .../string-functions/regexp/regexp_replace.md | 2 +- .../string-functions/like/like.md | 28 +++++++++++++---- .../string-functions/like/not_like.md | 31 ++++++++++++++----- .../string-functions/regexp/not_regexp.md | 2 +- .../string-functions/regexp/regexp.md | 2 +- 9 files changed, 97 insertions(+), 31 deletions(-) diff --git a/docs/en/sql-reference/sql-functions/string-functions/like/like.md b/docs/en/sql-reference/sql-functions/string-functions/like/like.md index 6fcbdf4cb3..48affd6c87 100644 --- a/docs/en/sql-reference/sql-functions/string-functions/like/like.md +++ b/docs/en/sql-reference/sql-functions/string-functions/like/like.md @@ -28,23 +28,39 @@ under the License. ## description ### syntax -'BOOLEAN like(VARCHAR str, VARCHAR pattern)' +`BOOLEAN like(VARCHAR str, VARCHAR pattern)` Perform fuzzy matching on the string str, return true if it matches, and false if it doesn't match. like match/fuzzy match, will be used in combination with % and _. -'a' // Precise matching, the same effect as `=`. +the percent sign ('%') represents zero, one, or more characters. + +the underscore ('_') represents a single character. + +``` +'a' // Precise matching, the same effect as `=` '%a' // data ending with a 'a%' // data starting with a '%a%' // data containing a -'_a_' // Three digits and the middle letter is a -'_a' // Two digits and the ending letter is a -'a_' // Two digits and the initial letter is a - +'_a_' // three digits and the middle letter is a +'_a' // two digits and the ending letter is a +'a_' // two digits and the initial letter is a +'a__b' // four digits, starting letter is a and ending letter is b +``` ## example ``` +// table test ++-------+ +| k1 | ++-------+ +| b | +| bb | +| bab | +| a | ++-------+ + // Return the data containing a in the k1 string mysql> select k1 from test where k1 like '%a%'; +-------+ diff --git a/docs/en/sql-reference/sql-functions/string-functions/like/not_like.md b/docs/en/sql-reference/sql-functions/string-functions/like/not_like.md index 3bfeaf0cbe..3ac280ff14 100644 --- a/docs/en/sql-reference/sql-functions/string-functions/like/not_like.md +++ b/docs/en/sql-reference/sql-functions/string-functions/like/not_like.md @@ -28,23 +28,39 @@ under the License. ## description ### syntax -'BOOLEAN not like(VARCHAR str, VARCHAR pattern)' +`BOOLEAN not like(VARCHAR str, VARCHAR pattern)` Perform fuzzy matching on the string str, return false if it matches, and return true if it doesn't match. like match/fuzzy match, will be used in combination with % and _. -'a' // Precise matching, the same effect as `=`. +the percent sign ('%') represents zero, one, or more characters. + +the underscore ('_') represents a single character. + +``` +'a' // Precise matching, the same effect as `=` '%a' // data ending with a 'a%' // data starting with a '%a%' // data containing a -'_a_' // Three digits and the middle letter is a -'_a' // Two digits and the ending letter is a -'a_' // Two digits and the initial letter is a - +'_a_' // three digits and the middle letter is a +'_a' // two digits and the ending letter is a +'a_' // two digits and the initial letter is a +'a__b' // four digits, starting letter is a and ending letter is b +``` ## example ``` +// table test ++-------+ +| k1 | ++-------+ +| b | +| bb | +| bab | +| a | ++-------+ + // Return data that does not contain a in the k1 string mysql> select k1 from test where k1 not like '%a%'; +-------+ @@ -59,8 +75,9 @@ mysql> select k1 from test where k1 not like 'a'; +-------+ | k1 | +-------+ -| bab | | b | +| bb | +| bab | +-------+ ``` diff --git a/docs/en/sql-reference/sql-functions/string-functions/regexp/not_regexp.md b/docs/en/sql-reference/sql-functions/string-functions/regexp/not_regexp.md index 7c5b94d2f8..400138736a 100644 --- a/docs/en/sql-reference/sql-functions/string-functions/regexp/not_regexp.md +++ b/docs/en/sql-reference/sql-functions/string-functions/regexp/not_regexp.md @@ -28,7 +28,7 @@ under the license. ## description ### syntax -'BOOLEAN not regexp(VARCHAR str, VARCHAR pattern)' +`BOOLEAN not regexp(VARCHAR str, VARCHAR pattern)` Perform regular matching on the string str, return false if it matches, and return true if it doesn't match. pattern is a regular expression. diff --git a/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp.md b/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp.md index 221cf7e68d..f45f9e48a3 100644 --- a/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp.md +++ b/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp.md @@ -28,7 +28,7 @@ under the License. ## description ### syntax -'BOOLEAN regexp(VARCHAR str, VARCHAR pattern)' +`BOOLEAN regexp(VARCHAR str, VARCHAR pattern)` Perform regular matching on the string str, return true if it matches, and return false if it doesn't match. pattern is a regular expression. diff --git a/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp_replace.md b/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp_replace.md index 1eeff8fdeb..c7524dd4e3 100644 --- a/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp_replace.md +++ b/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp_replace.md @@ -28,7 +28,7 @@ under the License. ## description ### Syntax -`VARCHAR regexp_replace(VARCHAR str, VARCHAR pattern, VARCHAR repl) +`VARCHAR regexp_replace(VARCHAR str, VARCHAR pattern, VARCHAR repl)` Regular matching of STR strings, replacing the part hitting pattern with repl diff --git a/docs/zh-CN/sql-reference/sql-functions/string-functions/like/like.md b/docs/zh-CN/sql-reference/sql-functions/string-functions/like/like.md index 34a58d162b..710cdf4df2 100644 --- a/docs/zh-CN/sql-reference/sql-functions/string-functions/like/like.md +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/like/like.md @@ -28,23 +28,39 @@ under the License. ## description ### syntax -'BOOLEAN like(VARCHAR str, VARCHAR pattern)' +`BOOLEAN like(VARCHAR str, VARCHAR pattern)` 对字符串 str 进行模糊匹配,匹配上的则返回 true,没匹配上则返回 false。 like 匹配/模糊匹配,会与 % 和 _ 结合使用。 -'a' // 精准匹配,和 `=` 效果一致。 +百分号 '%' 代表零个、一个或多个字符。 + +下划线 '_' 代表单个字符。 + +``` +'a' // 精准匹配,和 `=` 效果一致 '%a' // 以a结尾的数据 'a%' // 以a开头的数据 '%a%' // 含有a的数据 -'_a_' // 三位且中间字母是 a 的 -'_a' // 两位且结尾字母是 a 的 -'a_' // 两位且开头字母是 a 的 - +'_a_' // 三位且中间字符是 a的数据 +'_a' // 两位且结尾字符是 a的数据 +'a_' // 两位且开头字符是 a的数据 +'a__b' // 四位且以字符a开头、b结尾的数据 +``` ## example ``` +// table test ++-------+ +| k1 | ++-------+ +| b | +| bb | +| bab | +| a | ++-------+ + // 返回 k1 字符串中包含 a 的数据 mysql > select k1 from test where k1 like '%a%'; +-------+ diff --git a/docs/zh-CN/sql-reference/sql-functions/string-functions/like/not_like.md b/docs/zh-CN/sql-reference/sql-functions/string-functions/like/not_like.md index 9960f32f69..776acab475 100644 --- a/docs/zh-CN/sql-reference/sql-functions/string-functions/like/not_like.md +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/like/not_like.md @@ -28,23 +28,39 @@ under the License. ## description ### syntax -'BOOLEAN not like(VARCHAR str, VARCHAR pattern)' +`BOOLEAN not like(VARCHAR str, VARCHAR pattern)` 对字符串 str 进行模糊匹配,匹配上的则返回 false,没匹配上则返回 true。 like 匹配/模糊匹配,会与 % 和 _ 结合使用。 -'a' // 精准匹配,和 `=` 效果一致。 +百分号 '%' 代表零个、一个或多个字符。 + +下划线 '_' 代表单个字符。 + +``` +'a' // 精准匹配,和 `=` 效果一致 '%a' // 以a结尾的数据 'a%' // 以a开头的数据 '%a%' // 含有a的数据 -'_a_' // 三位且中间字母是 a 的 -'_a' // 两位且结尾字母是 a 的 -'a_' // 两位且开头字母是 a 的 - +'_a_' // 三位且中间字母是 a 的数据 +'_a' // 两位且结尾字母是 a 的数据 +'a_' // 两位且开头字母是 a 的数据 +'a__b' // 四位且以字符a开头、b结尾的数据 +``` ## example ``` +// table test ++-------+ +| k1 | ++-------+ +| b | +| bb | +| bab | +| a | ++-------+ + // 返回 k1 字符串中不包含 a 的数据 mysql > select k1 from test where k1 not like '%a%'; +-------+ @@ -59,8 +75,9 @@ mysql > select k1 from test where k1 not like 'a'; +-------+ | k1 | +-------+ -| bab | | b | +| bb | +| bab | +-------+ ``` diff --git a/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/not_regexp.md b/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/not_regexp.md index 4d28e82b32..270a7e559b 100644 --- a/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/not_regexp.md +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/not_regexp.md @@ -28,7 +28,7 @@ under the License. ## description ### syntax -'BOOLEAN not regexp(VARCHAR str, VARCHAR pattern)' +`BOOLEAN not regexp(VARCHAR str, VARCHAR pattern)` 对字符串 str 进行正则匹配,匹配上的则返回 false,没匹配上则返回 true。pattern 为正则表达式。 diff --git a/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp.md b/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp.md index 3f59b3643b..fec12960a8 100644 --- a/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp.md +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp.md @@ -28,7 +28,7 @@ under the License. ## description ### syntax -'BOOLEAN regexp(VARCHAR str, VARCHAR pattern)' +`BOOLEAN regexp(VARCHAR str, VARCHAR pattern)` 对字符串 str 进行正则匹配,匹配上的则返回 true,没匹配上则返回 false。pattern 为正则表达式。