Skip to content

Commit d7e24a5

Browse files
authored
Add/update expression functions (#10257)
* Add/update expression functions fixes #10255 * Use 'string' instead of 'input'
1 parent 0c6e846 commit d7e24a5

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

docs/user_manual/expressions/expression_help/GeometryGroup.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,8 @@ Returns the number of geometries in a geometry collection, or the number of part
20802080
* - Arguments
20812081
- * **geometry** - geometry collection or multi-part geometry
20822082
* - Examples
2083-
- * ``num_geometries(geom_from_wkt('GEOMETRYCOLLECTION(POINT(0 1), POINT(0 0), POINT(1 0), POINT(1 1))'))`` → 4
2083+
- * ``num_geometries(@geometry)`` → number of geometries or number of parts of the current feature's geometry
2084+
* ``num_geometries(geom_from_wkt('GEOMETRYCOLLECTION(POINT(0 1), POINT(0 0), POINT(1 0), POINT(1 1))'))`` → 4
20842085
* ``num_geometries(geom_from_wkt('MULTIPOINT((0 1), (0 0), (1 0))'))`` → 3
20852086

20862087

docs/user_manual/expressions/expression_help/String.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,44 @@ Returns a part of a string.
604604

605605
.. end_substr_section
606606
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).
613+
614+
.. list-table::
615+
:widths: 15 85
616+
617+
* - Syntax
618+
- substr_count(string, substring, [overlapping=False])
619+
620+
[] marks optional arguments
621+
* - Arguments
622+
- * **string** - The input string to search in.
623+
* **substring** - The substring to search for.
624+
* **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.
641+
642+
643+
.. end_substr_count_section
644+
607645
.. _expression_function_String_title:
608646

609647
title

0 commit comments

Comments
 (0)