Edit: removed text that caret is obsolete. Upd.: I think my example (now striked-thourgh) simply reduces to the same but without look-ahead; see comment by Lanx.
Comment on Re: How to enforce match priority irrespective of string position
Of course, '$re_cond_1' may be not equal to '$re_match_1'. But I wanted to show the simplest example. Further '\1' can be used to avoid self-repeating.
I must say that this syntax confuses me. I am already using a lookahead to define the forward edge of the match (versus where the next match will start in the global substitution), and everything up to but not including that lookahead needs to be captured. I've never thought one could capture from a lookahead...but perhaps I'd misunderstood. I'm also using backslash lookaround assertions, because some of what is matched will be matched again (these are the false positives) and for an unpredictable number of times (fewer than 20).
I tried putting rsFalse's suggestion to use but was unable to get the match to succeed. I don't think I understand it well enough.
you can separate the "condition to match" (in the lookahead) from the actual match-pattern.
Point is that a failed partial match might move the pos forward, but if the condition fails pos won't be changed before trying the next or-alternative.