diff --git a/docs/.vuepress/sidebar/en.js b/docs/.vuepress/sidebar/en.js index bf40bd3335..ce584d086c 100644 --- a/docs/.vuepress/sidebar/en.js +++ b/docs/.vuepress/sidebar/en.js @@ -314,8 +314,6 @@ module.exports = [ "ltrim", "money_format", "null_or_empty", - "regexp_extract", - "regexp_replace", "repeat", "reverse", "right", @@ -324,6 +322,24 @@ module.exports = [ "starts_with", "strleft", "strright", + { + title: "fuzzy match", + directoryPath: "like/", + children: [ + "like", + "not_like", + ], + }, + { + title: "regular match", + directoryPath: "regexp/", + children: [ + "regexp", + "regexp_extract", + "regexp_replace", + "not_regexp", + ], + }, ], }, { diff --git a/docs/.vuepress/sidebar/zh-CN.js b/docs/.vuepress/sidebar/zh-CN.js index e9ef97be8f..1e7acc6fa1 100644 --- a/docs/.vuepress/sidebar/zh-CN.js +++ b/docs/.vuepress/sidebar/zh-CN.js @@ -319,8 +319,6 @@ module.exports = [ "ltrim", "money_format", "null_or_empty", - "regexp_extract", - "regexp_replace", "repeat", "reverse", "right", @@ -329,6 +327,24 @@ module.exports = [ "starts_with", "strleft", "strright", + { + title: "模糊匹配", + directoryPath: "like/", + children: [ + "like", + "not_like", + ], + }, + { + title: "正则匹配", + directoryPath: "regexp/", + children: [ + "regexp", + "regexp_extract", + "regexp_replace", + "not_regexp", + ], + }, ], }, { diff --git a/docs/en/sql-reference/sql-functions/string-functions/append_trailing_char_if_absent.md b/docs/en/sql-reference/sql-functions/string-functions/append_trailing_char_if_absent.md index cd24883ff0..6895c3e33c 100644 --- a/docs/en/sql-reference/sql-functions/string-functions/append_trailing_char_if_absent.md +++ b/docs/en/sql-reference/sql-functions/string-functions/append_trailing_char_if_absent.md @@ -32,8 +32,8 @@ under the License. `VARCHAR append_trailing_char_if_absent(VARCHAR str, VARCHAR trailing_char)` -If the s string is non-empty and does not contain the c character at the end, it appends the c character to the end. -Trailing_char contains only one character, and it will return NULL if contains more than one character +If the @str string is non-empty and does not contain the @trailing_char character at the end, it appends the @trailing_char character to the end. +@trailing_char contains only one character, and it will return NULL if contains more than one character ## example 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 new file mode 100644 index 0000000000..6fcbdf4cb3 --- /dev/null +++ b/docs/en/sql-reference/sql-functions/string-functions/like/like.md @@ -0,0 +1,67 @@ +--- +{ + "title": "like", + "language": "en" +} +--- + + + +# like +## description +### syntax + +'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 `=`. +'%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 + +## example + +``` +// Return the data containing a in the k1 string +mysql> select k1 from test where k1 like '%a%'; ++-------+ +| k1 | ++-------+ +| a | +| bab | ++-------+ + +// Return the data equal to a in the k1 string +mysql> select k1 from test where k1 like 'a'; ++-------+ +| k1 | ++-------+ +| a | ++-------+ +``` + +## keyword +LIKE 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 new file mode 100644 index 0000000000..3bfeaf0cbe --- /dev/null +++ b/docs/en/sql-reference/sql-functions/string-functions/like/not_like.md @@ -0,0 +1,68 @@ +--- +{ + "title": "not like", + "language": "en" +} +--- + + + +# not like +## description +### syntax + +'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 `=`. +'%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 + +## example + +``` +// Return data that does not contain a in the k1 string +mysql> select k1 from test where k1 not like '%a%'; ++-------+ +| k1 | ++-------+ +| b | +| bb | ++-------+ + +// Return the data that is not equal to a in the k1 string +mysql> select k1 from test where k1 not like 'a'; ++-------+ +| k1 | ++-------+ +| bab | +| b | ++-------+ +``` + +## keyword +LIKE, NOT, NOT LIKE 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 new file mode 100644 index 0000000000..7c5b94d2f8 --- /dev/null +++ b/docs/en/sql-reference/sql-functions/string-functions/regexp/not_regexp.md @@ -0,0 +1,56 @@ +--- +{ + "title": "not regexp", + "language": "en" +} +--- + + + +# not regexp +## description +### syntax + +'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. + +## example + +``` +// Find all data in the k1 field that does not start with 'billie' +mysql> select k1 from test where k1 not regexp '^billie'; ++--------------------+ +| k1 | ++--------------------+ +| Emmy eillish | ++--------------------+ + +// Find all the data in the k1 field that does not end with 'ok': +mysql> select k1 from test where k1 not regexp 'ok$'; ++------------+ +| k1 | ++------------+ +| It's true | ++------------+ +``` + +## keyword +REGEXP, NOT, NOT REGEXP 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 new file mode 100644 index 0000000000..221cf7e68d --- /dev/null +++ b/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp.md @@ -0,0 +1,56 @@ +--- +{ + "title": "regexp", + "language": "en" +} +--- + + + +# regexp +## description +### syntax + +'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. + +## example + +``` +// Find all data starting with 'billie' in the k1 field +mysql> select k1 from test where k1 regexp '^billie'; ++--------------------+ +| k1 | ++--------------------+ +| billie eillish | ++--------------------+ + +// Find all data ending with 'ok' in the k1 field: +mysql> select k1 from test where k1 regexp 'ok$'; ++----------+ +| k1 | ++----------+ +| It's ok | ++----------+ +``` + +## keyword +REGEXP diff --git a/docs/en/sql-reference/sql-functions/string-functions/regexp_extract.md b/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp_extract.md similarity index 100% rename from docs/en/sql-reference/sql-functions/string-functions/regexp_extract.md rename to docs/en/sql-reference/sql-functions/string-functions/regexp/regexp_extract.md diff --git a/docs/en/sql-reference/sql-functions/string-functions/regexp_replace.md b/docs/en/sql-reference/sql-functions/string-functions/regexp/regexp_replace.md similarity index 100% rename from docs/en/sql-reference/sql-functions/string-functions/regexp_replace.md rename to docs/en/sql-reference/sql-functions/string-functions/regexp/regexp_replace.md diff --git a/docs/zh-CN/sql-reference/sql-functions/string-functions/append_trailing_char_if_absent.md b/docs/zh-CN/sql-reference/sql-functions/string-functions/append_trailing_char_if_absent.md index b6770ef2a0..3250d00c9f 100644 --- a/docs/zh-CN/sql-reference/sql-functions/string-functions/append_trailing_char_if_absent.md +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/append_trailing_char_if_absent.md @@ -32,8 +32,8 @@ under the License. `VARCHAR append_trailing_char_if_absent(VARCHAR str, VARCHAR trailing_char)` -如果's'字符串非空并且末尾不包含'c'字符,则将'c'字符附加到末尾。 -trailing_char只包含一个字符,如果包含多个字符,将返回NULL +如果 str 字符串非空并且末尾不包含 trailing_char 字符,则将 trailing_char 字符附加到末尾。 +trailing_char 只能包含一个字符,如果包含多个字符,将返回NULL ## example 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 new file mode 100644 index 0000000000..34a58d162b --- /dev/null +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/like/like.md @@ -0,0 +1,67 @@ +--- +{ + "title": "like", + "language": "zh-CN" +} +--- + + + +# like +## description +### syntax + +'BOOLEAN like(VARCHAR str, VARCHAR pattern)' + +对字符串 str 进行模糊匹配,匹配上的则返回 true,没匹配上则返回 false。 + +like 匹配/模糊匹配,会与 % 和 _ 结合使用。 + +'a' // 精准匹配,和 `=` 效果一致。 +'%a' // 以a结尾的数据 +'a%' // 以a开头的数据 +'%a%' // 含有a的数据 +'_a_' // 三位且中间字母是 a 的 +'_a' // 两位且结尾字母是 a 的 +'a_' // 两位且开头字母是 a 的 + +## example + +``` +// 返回 k1 字符串中包含 a 的数据 +mysql > select k1 from test where k1 like '%a%'; ++-------+ +| k1 | ++-------+ +| a | +| bab | ++-------+ + +// 返回 k1 字符串中等于 a 的数据 +mysql > select k1 from test where k1 like 'a'; ++-------+ +| k1 | ++-------+ +| a | ++-------+ +``` + +## keyword +LIKE 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 new file mode 100644 index 0000000000..9960f32f69 --- /dev/null +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/like/not_like.md @@ -0,0 +1,68 @@ +--- +{ + "title": "not like", + "language": "zh-CN" +} +--- + + + +# not like +## description +### syntax + +'BOOLEAN not like(VARCHAR str, VARCHAR pattern)' + +对字符串 str 进行模糊匹配,匹配上的则返回 false,没匹配上则返回 true。 + +like 匹配/模糊匹配,会与 % 和 _ 结合使用。 + +'a' // 精准匹配,和 `=` 效果一致。 +'%a' // 以a结尾的数据 +'a%' // 以a开头的数据 +'%a%' // 含有a的数据 +'_a_' // 三位且中间字母是 a 的 +'_a' // 两位且结尾字母是 a 的 +'a_' // 两位且开头字母是 a 的 + +## example + +``` +// 返回 k1 字符串中不包含 a 的数据 +mysql > select k1 from test where k1 not like '%a%'; ++-------+ +| k1 | ++-------+ +| b | +| bb | ++-------+ + +// 返回 k1 字符串中不等于 a 的数据 +mysql > select k1 from test where k1 not like 'a'; ++-------+ +| k1 | ++-------+ +| bab | +| b | ++-------+ +``` + +## keyword +LIKE, NOT, NOT LIKE 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 new file mode 100644 index 0000000000..4d28e82b32 --- /dev/null +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/not_regexp.md @@ -0,0 +1,56 @@ +--- +{ + "title": "not regexp", + "language": "zh-CN" +} +--- + + + +# not regexp +## description +### syntax + +'BOOLEAN not regexp(VARCHAR str, VARCHAR pattern)' + +对字符串 str 进行正则匹配,匹配上的则返回 false,没匹配上则返回 true。pattern 为正则表达式。 + +## example + +``` +// 查找 k1 字段中不以 'billie' 为开头的所有数据 +mysql > select k1 from test where k1 not regexp '^billie'; ++--------------------+ +| k1 | ++--------------------+ +| Emmy eillish | ++--------------------+ + +// 查找 k1 字段中不以 'ok' 为结尾的所有数据: +mysql > select k1 from test where k1 not regexp 'ok$'; ++------------+ +| k1 | ++------------+ +| It's true | ++------------+ +``` + +## keyword +REGEXP, NOT, NOT REGEXP 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 new file mode 100644 index 0000000000..3f59b3643b --- /dev/null +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp.md @@ -0,0 +1,56 @@ +--- +{ + "title": "regexp", + "language": "zh-CN" +} +--- + + + +# regexp +## description +### syntax + +'BOOLEAN regexp(VARCHAR str, VARCHAR pattern)' + +对字符串 str 进行正则匹配,匹配上的则返回 true,没匹配上则返回 false。pattern 为正则表达式。 + +## example + +``` +// 查找 k1 字段中以 'billie' 为开头的所有数据 +mysql > select k1 from test where k1 regexp '^billie'; ++--------------------+ +| k1 | ++--------------------+ +| billie eillish | ++--------------------+ + +// 查找 k1 字段中以 'ok' 为结尾的所有数据: +mysql > select k1 from test where k1 regexp 'ok$'; ++----------+ +| k1 | ++----------+ +| It's ok | ++----------+ +``` + +## keyword +REGEXP diff --git a/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp_extract.md b/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp_extract.md similarity index 99% rename from docs/zh-CN/sql-reference/sql-functions/string-functions/regexp_extract.md rename to docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp_extract.md index a372f1347c..737721a5a4 100644 --- a/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp_extract.md +++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp_extract.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -42,7 +40,6 @@ mysql> SELECT regexp_extract('AbCdE', '([[:lower:]]+)C([[:lower:]]+)', 1); +-------------------------------------------------------------+ | b | +-------------------------------------------------------------+ - mysql> SELECT regexp_extract('AbCdE', '([[:lower:]]+)C([[:lower:]]+)', 2); +-------------------------------------------------------------+ | regexp_extract('AbCdE', '([[:lower:]]+)C([[:lower:]]+)', 2) | diff --git a/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp_replace.md b/docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp_replace.md similarity index 100% rename from docs/zh-CN/sql-reference/sql-functions/string-functions/regexp_replace.md rename to docs/zh-CN/sql-reference/sql-functions/string-functions/regexp/regexp_replace.md