logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

count-substring - (strings)

Description

count-substring counts the number of occurrences of <substring> in <string> and stores the result in <count> (specified in "to" clause). By default, search is case-sensitive. If you use "case-insensitive" clause without boolean variable <case insensitive>, or if <case insensitive> evaluates to true, then the search is case-insensitive. If <substring> is empty (""), <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): set-string sub = "world" set-string str = "Hello world and hello World!" count-substring sub in str to num_occ print-format "Found %ld occurrences!\n", num_occ count-substring sub in str to num_occ case-insensitive print-format "Found %ld occurrences!\n", num_occ

Name

count-substring - (strings)

Purpose

Count substrings.

See Also

Strings concatenate-stringscopy-stringcount-substringdelete-stringlower-stringnew-stringread-splitreplace-stringset-stringsplit-stringstring-lengthtrim-stringupper-stringwrite-string See all documentation $DATE $VERSION GOLF(2gg)

Syntax

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

See Also