You can also use regular expression
~r/#{Regex.escape(substring)}/
|> Regex.scan(string, return: :index)
This returns the indices and lengths of all matching parts as [[{index1, length1}], [{index2, length2}], ...]
You can also use regular expression
~r/#{Regex.escape(substring)}/
|> Regex.scan(string, return: :index)
This returns the indices and lengths of all matching parts as [[{index1, length1}], [{index2, length2}], ...]