Private/Get-KadenMarkerCount.ps1
|
function Get-KadenMarkerCount { <# .SYNOPSIS Count non-overlapping occurrences of a marker token. #> [CmdletBinding()] param( [Parameter(Mandatory = $true)] [AllowEmptyString()] [string]$Text, [Parameter(Mandatory = $true)] [string]$Token ) $count = 0 $index = 0 while ($index -le $Text.Length) { $found = $Text.IndexOf($Token, $index) if ($found -lt 0) { break } $count++ $index = $found + $Token.Length } return $count } |