andgineer / TRegExpr

Regular expressions (regex), pascal.
https://regex.sorokin.engineer/en/latest/
MIT License
174 stars 63 forks source link

Reminder for me: \K #203

Closed Alexey-T closed 1 year ago

Alexey-T commented 4 years ago

k

https://regular-expressions.mobi/keep.html?wlr=1

Alexey-T commented 4 years ago

Proposal how to implement \K for all choices for all groups (nested too)

Add class field regParseK

Add opcode OP_K which will store current pos (regParse?) to regParseK

MatchPrim calls itself. On enter, it clears regParseK, on found result it maybe has set regParseK (if op_k was present). Outer MatchPrim checks if regParseK is set- if yes, it adjusts result of called MatchPrim, clears regParseK (must clear to not affect outer matchprim calls).