While browsing I've bumped into a mindblowingly useful tool when it comes to regular expressions: Lookaround Zero-Length Assertions - https://www.regular-expressions.info/lookaround.html .
It's that thing, that set of characters, which makes your search capable of matching, for example, (beginning of a line)#
, but only, if the #
is preceded by |
and then NEWLINE
- like in orgmode spreadsheets the first of multiple formulas. So, the context behind or before is considered for matching without this context to be added into the result string as additional characters.
What made me understand this in the first place was this section:
Lookbehind has the same effect, but works backwards. It tells the regex engine to temporarily step backwards in the string, to check if the text inside the lookbehind can be matched there. (?<!a)b matches a “b” that is not preceded by an “a”,
Some research revealed that there seemed to be some effort going on to add this feature to emacs: https://emacs.stackexchange.com/a/32782
The question now is: 2023/2024 - can any of the emacs versions newer than 24.1 do it? Because this is really a great feature, irreplaceable valuable.