toOffset

fun Position.toOffset(text: String): Int

Converts a Position to a character offset (index) in the text.

Return

the character offset corresponding to the given position, or -1 if the position is out of bounds

Parameters

text

the text content to search in