Skip to main content

Description

Finds all occurrences of a substring within a string, returning an array of all matching positions. Optionally search within a specific range.

Syntax

Parameters

Returns

Type: list of numbers An array containing the zero-based indices of all occurrences of the substring. Returns an empty array if no matches are found. Returns null if the input string is null.

Examples

Example 1: Find All Occurrences

Output:

Example 2: Find Occurrences in Range

Output:
(Skips first ‘abc’ at position 0, finds those within range)

Example 3: Count Keyword Occurrences

Notes

  • Returns null if input string is null
  • Returns empty array if substring is not found
  • Uses zero-based indexing
  • The from parameter allows starting search from a specific position
  • The to parameter limits search to a specific range
  • Useful for counting occurrences or analyzing text patterns

See Also

Frequently Asked Questions

It returns an empty list [].
Yes. Use the optional from and to parameters to restrict the search within a substring range.