This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git


The following commit(s) were added to refs/heads/master by this push:
     new cd37bed67f [doc](function)support count_substrings functions (#1211)
cd37bed67f is described below

commit cd37bed67f2af75e42690685169efb9b1c77a1e3
Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com>
AuthorDate: Wed Oct 23 22:29:39 2024 +0800

    [doc](function)support count_substrings functions (#1211)
    
    # Versions
    
    - [x] dev
    - [ ] 3.0
    - [ ] 2.1
    - [ ] 2.0
    
    # Languages
    
    - [x] Chinese
    - [x] English
---
 .../string-functions/count_substrings.md           | 107 ++++++++++++++++++++
 .../string-functions/count_substrings.md           | 108 +++++++++++++++++++++
 sidebars.json                                      |   1 +
 3 files changed, 216 insertions(+)

diff --git a/docs/sql-manual/sql-functions/string-functions/count_substrings.md 
b/docs/sql-manual/sql-functions/string-functions/count_substrings.md
new file mode 100644
index 0000000000..91fea9b163
--- /dev/null
+++ b/docs/sql-manual/sql-functions/string-functions/count_substrings.md
@@ -0,0 +1,107 @@
+---
+{
+    "title": "COUNT_SUBSTRINGS",
+    "language": "en"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+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
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## count_substrings
+
+### description
+
+#### Syntax
+
+`int count_substrings(STRING str, STRING pattern)`
+Returns the total number of occurrences of the substring pattern in the string 
str.
+Note: The current implementation shifts by the length of the pattern after 
each match in the string.
+Therefore, when str: ccc and pattern: cc, the result returned is 1.
+
+#### Arguments
+
+`str` — The string to be checked. Type: `String`
+`pattern` — The substring to be matched. Type: `String`
+
+
+#### Returned value(s)
+
+Returns the total number of occurrences of the substring.
+
+### example
+
+```
+mysql [(none)]>select count_substrings('a1b1c1d','1');
++----------------------------------+
+| count_substrings('a1b1c1d', '1') |
++----------------------------------+
+|                                3 |
++----------------------------------+
+
+mysql [(none)]>select count_substrings(',,a,b,c,',',');
++-----------------------------------+
+| count_substrings(',,a,b,c,', ',') |
++-----------------------------------+
+|                                 5 |
++-----------------------------------+
+
+mysql [(none)]>select count_substrings('ccc','cc');
++--------------------------------+
+| count_substrings('ccc', 'cc')  |
++--------------------------------+
+|                              1 |
++--------------------------------+
+
+mysql [(none)]>SELECT count_substrings(NULL,',');
++-----------------------------+
+| count_substrings(NULL, ',') |
++-----------------------------+
+|                        NULL |
++-----------------------------+
+
+mysql [(none)]>select count_substrings('a,b,c,abcde','');
++-------------------------------------+
+| count_substrings('a,b,c,abcde', '') |
++-------------------------------------+
+|                                   0 |
++-------------------------------------+
+
+mysql [(none)]>select count_substrings(NULL, 'a');
++-----------------------------+
+| count_substrings(NULL, 'a') |
++-----------------------------+
+|                        NULL |
++-----------------------------+
+
+mysql [(none)]>select count_substrings('','asd');
++-----------------------------+
+| count_substrings('', 'asd') |
++-----------------------------+
+|                           0 |
++-----------------------------+
+
+mysql [(none)]>select count_substrings('abccbaacb','c');
++------------------------------------+
+| count_substrings('abccbaacb', 'c') |
++------------------------------------+
+|                                  3 |
++------------------------------------+
+```
+### keywords
+
+COUNT_SUBSTRINGS,SUBSTRINGS
\ No newline at end of file
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/string-functions/count_substrings.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/string-functions/count_substrings.md
new file mode 100644
index 0000000000..633d66f5bf
--- /dev/null
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/string-functions/count_substrings.md
@@ -0,0 +1,108 @@
+---
+{
+    "title": "COUNT_SUBSTRINGS",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+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
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## count_substrings
+
+### description
+
+#### Syntax
+
+`int count_substrings(STRING str, STRING pattern)`
+返回字符串str中包含子串pattern的总个数。
+注意: 当前实现为在str 中每匹配到子串时,就会偏移一个子串长度继续寻找
+所以当`str:ccc, pattern:cc` 时,返回结果为1
+
+#### Arguments
+
+`str` — 需要检测的字符串. 类型: `String`
+`pattern` — 是用来被匹配的子串. 类型: `String`
+
+
+#### Returned value(s)
+
+返回一个包含子字符串的总个数.
+
+### example
+
+```
+mysql [(none)]>select count_substrings('a1b1c1d','1');
++----------------------------------+
+| count_substrings('a1b1c1d', '1') |
++----------------------------------+
+|                                3 |
++----------------------------------+
+
+mysql [(none)]>select count_substrings(',,a,b,c,',',');
++-----------------------------------+
+| count_substrings(',,a,b,c,', ',') |
++-----------------------------------+
+|                                 5 |
++-----------------------------------+
+
+mysql [(none)]>select count_substrings('ccc','cc');
++--------------------------------+
+| count_substrings('ccc', 'cc')  |
++--------------------------------+
+|                              1 |
++--------------------------------+
+
+
+mysql [(none)]>SELECT count_substrings(NULL,',');
++-----------------------------+
+| count_substrings(NULL, ',') |
++-----------------------------+
+|                        NULL |
++-----------------------------+
+
+mysql [(none)]>select count_substrings('a,b,c,abcde','');
++-------------------------------------+
+| count_substrings('a,b,c,abcde', '') |
++-------------------------------------+
+|                                   0 |
++-------------------------------------+
+
+mysql [(none)]>select count_substrings(NULL, 'a');
++-----------------------------+
+| count_substrings(NULL, 'a') |
++-----------------------------+
+|                        NULL |
++-----------------------------+
+
+mysql [(none)]>select count_substrings('','asd');
++-----------------------------+
+| count_substrings('', 'asd') |
++-----------------------------+
+|                           0 |
++-----------------------------+
+
+mysql [(none)]>select count_substrings('abccbaacb','c');
++------------------------------------+
+| count_substrings('abccbaacb', 'c') |
++------------------------------------+
+|                                  3 |
++------------------------------------+
+```
+### keywords
+
+COUNT_SUBSTRINGS,SUBSTRINGS
diff --git a/sidebars.json b/sidebars.json
index b42007302b..cf31941c15 100644
--- a/sidebars.json
+++ b/sidebars.json
@@ -928,6 +928,7 @@
                                 
"sql-manual/sql-functions/string-functions/concat",
                                 
"sql-manual/sql-functions/string-functions/concat-ws",
                                 
"sql-manual/sql-functions/string-functions/substring",
+                                
"sql-manual/sql-functions/string-functions/count_substrings",
                                 
"sql-manual/sql-functions/string-functions/sub-replace",
                                 
"sql-manual/sql-functions/string-functions/append-trailing-char-if-absent",
                                 
"sql-manual/sql-functions/string-functions/ends-with",


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to