string_find

Finds a string within the search range of an input string.

The substring is searched in the given range start at start and ending just before end, that is, in the range [start, end).

If the reverse flag is toggled, the input string is searched backwards, from stop to just before start, that is, in the [stop, start).

The function returns whether the substring has been found in the specified range and the index, from the beginning of the input string, where the substring has been found.

Inputs

string

The input string.

find

The substring to be searched in the input string.

reverse

Flag indicating the direction of the string search.

start

The beginning of the search range.

end

The end of the search range.

Outputs

found

Flag indicating whether the substring has been found in the input string or not.

index

The position of the found substring withing the input string, or -1 if no substring has been found in the given search range.