getWordRangeAtPosition

abstract fun getWordRangeAtPosition(position: Position, regex: RegExp = definedExternally): Range?(source)

Get a word-range at the given position. By default words are defined by common separators, like space, -, _, etc. In addition, per language custom word definitions can be defined. It is also possible to provide a custom regular expression.

  • Note 1: A custom regular expression must not match the empty string and if it does, it will be ignored.

  • Note 2: A custom regular expression will fail to match multiline strings and in the name of speed regular expressions should not match words with spaces. Use {@linkcode TextLine.text} for more complex, non-wordy, scenarios.

The position will be adjusted.

Parameters

position

A position.

regex

Optional regular expression that describes what a word is.