Get the caret position in a multiline input

I’d love if someone could help me with this. I need to get text before the caret and use it as an input.

I can do this by using an arbitrary text and splitting the text, but I would like to have a more elegant solution.

Any thoughts?

I’d really love an answer to this.

I want to copy the text before the cursor (caret) in a Rich Text Box multiline input and use the copied text as an input to another field. Any thoughts on this?