Vely logo install
examples
documentation

Vely 15.2.0 released on Jan 18, 2023
Articles updated Jan 17, 2023

count-substring


Issues with this documentation page? Report here.

Purpose:


Count substrings.

Syntax:



count-substring <substring> in <string> to [ define ] <count> [ case-insensitive ]


Description:


count-substring counts the number of occurrences of <substring> in <string> and stores the result in <count> (specified in "to" clause), which can be created with "define" if it does not exist. By default, search is case-sensitive. If you use "case-insensitive" clause, however, the search is case-insensitive.

If <substring> is empty ("") or NULL, <count> is 0.

Examples:


In the following example, 1 occurrence will be found after the first count-substring, and 2 after the second (since case insensitive search is used there):

char sub[] = "world";
char str[] = "Hello world and hello World!";

count-substring sub in str to define num_occ
pf-out "Found %lld occurrences!\n", num_occ

count-substring sub in str to num_occ case-insensitive
pf-out "Found %lld occurrences!\n", num_occ


See also:


Strings ( copy-string   count-substring   lower-string   split-string   trim-string   upper-string   write-string  )  SEE ALL (documentation)



Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. Vely elephant logo (c) 2022 DaSoftver LLC. This web page is licensed under CC-BY-SA-4.0.