Converts a Position to a character offset (index) in the text.
the character offset corresponding to the given position, or -1 if the position is out of bounds
the text content to search in