Rule only triggers once for a previous match and ignore the new one

I have such as rule which detects matches and inserts custom nodes each time it triggers (it replaces the match with the custom node)

const rules = [
   new InputRule(/\(*\s*(\w+)\s*\)*/, function (state, match, start, end) {
      // processing match

If i add the ‘$’ to the end of the regex, obviously it will detect matchs at the end of the line/string only but that’s an inconvenience because it’s needed also to make replacements at the begining or the middle of the string.

The problem is if there is not end of string restriction in the regex (no ‘$’), the rule will triggers only once for the first detected match and not for the next matches.

So if i try to add the condition that the match occured exactly at the left of the cursor/selection to make the replacement in that case the rule won’t trigger again anyway if a replacement didn’t proceed in the first match detected to make it in the latest detected match (as it won’t happen)

How to make it possible that a rule could trigger for all matches and not only for the first one ?!

Sounds like you are using input rules for something that they aren’t designed for. The docs clearly state the regexp should end with $.

Yes i saw the doc but it’s bummer since we still can move a cursor back and forth in the editor and it’d be great if we can make replacements everywhere in the doc