Count Substring
count_substringCount occurrences of a substring in text, with options for case sensitivity and overlapping matches. Returns the count and positions of each match.
Instructions
Count occurrences of a substring or pattern in text.
Can count overlapping or non-overlapping matches.
Args:
text (string): The text to search in
substring (string): The pattern to find
case_sensitive (boolean): Match case exactly (default: false)
overlapping (boolean): Count overlapping matches (default: false)
Returns: count and positions of each match.
Example: count_substring("banana", "ana", overlapping=true) → count: 2, positions: [1, 3]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The text to search in | |
| substring | Yes | The pattern to find | |
| overlapping | No | Count overlapping matches | |
| case_sensitive | No | Match case exactly |