You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user_manual/expressions/expression_help/String.rst
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -604,6 +604,44 @@ Returns a part of a string.
604
604
605
605
.. end_substr_section
606
606
607
+
.. _expression_function_String_substr_count:
608
+
609
+
substr_count
610
+
............
611
+
612
+
Counts the number of occurrences of a substring within a string. By default, the function counts non-overlapping occurrences (like in Python). If the third argument is set to true, the function counts overlapping occurrences (like in QT).
* **overlapping** - Optional flag to control whether overlapping occurrences should be counted. Defaults to FALSE (non-overlapping counting). Set to TRUE to count overlapping occurrences.
625
+
* - Examples
626
+
- * ``substr_count('banana', 'an')`` → 2
627
+
628
+
Counts non-overlapping occurrences of 'an' in 'banana'.
629
+
* ``substr_count('Funniness', 'n')`` → 3
630
+
631
+
Counts non-overlapping occurrences of 'n' in 'Funniness'.
632
+
* ``substr_count('aaaaa', 'aa')`` → 2
633
+
634
+
Counts non-overlapping occurrences of 'aa' in 'aaaaa'.
635
+
* ``substr_count('aaaaa', 'aa', true)`` → 4
636
+
637
+
Counts overlapping occurrences of 'aa' in 'aaaaa'. The substring 'aa' appears four times in an overlapping fashion.
638
+
* ``substr_count('BANANA', 'an')`` → 0
639
+
640
+
Counts non-overlapping occurrences of 'an' in 'BANANA'. Case-sensitive, so no match.
0 commit comments