Skip to content

Modern String Tally

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › String Library › String Library › Tally

Tally

Counts how many times the text occurs, without overlaps.

Syntax

Tally( s, match [, ic] )

Notes

  • O(n*m) — long

Examples

#import "std/strings"
using strings

dim as ustring csv = "a,b,,c"

print Tally( csv, "," )              '' 3 -- one per separator
print Tally( "aaaa", "aa" )          '' 2 -- occurrences never overlap
print Tally( "Hello", "L", true )    '' 2 -- ignoreCase
print Tally( csv, "" )               '' 0 -- an empty match counts nothing

Library: String Library
Category: String Library
Documented under: The Functions

Clone this wiki locally