in reply to Re^4: How to enforce match priority irrespective of string position
in thread How to enforce match priority irrespective of string position

Could you perhaps match repeatedly within the same string, in a loop, and then manually select what you consider to be the most appropriate match?
  • Comment on Re^5: How to enforce match priority irrespective of string position

Replies are listed 'Best First'.
Re^6: How to enforce match priority irrespective of string position
by Polyglot (Chaplain) on Mar 07, 2021 at 14:11 UTC

    Because of the complexity of the operation, I am actually matching a chunk at a time (it is this step where I've run into the "false positives" problem and need a priority-match solution) and then I am substituting via an evaluated subroutine which processes the captured chunk and returns the correct replacement. So, in a sense, I am doing this already--but in stages, via the subroutine.

    For the basic idea:

    $str = s~[my regex] ~print "DEBUG: 3:$3; 4:$4; 5:$5; 6:$6\n"; $procfootnote->()~egmx;

    I'm no stranger to regex...but regex is sufficiently complex that I doubt I'll ever fully master it!

    Blessings,

    ~Polyglot~