Example of using SearchCursor/RegExpCursor

Hi there! I need to search for a specific string and replace it with a Decoration object. Could someone give me an example of how to use it?

yeah I know, I could use syntaxTree.iterate but i can’t do that because of the string’s specific structure (invalid HTML code)

I’m looking for something similar that was in CM5:

const cursor = cm.getSearchCursor(regex, pos);

while (cursor.findNext()) {

See the docs for SearchCursor and RegExpCursor.

Thanks, it was the first thing I did, but I still have no idea how to use it.
ReqExpCursor requires Text as the first argument. Where should I get it?

From state.doc.