It sounds like you would like https://en.wikipedia.org/wiki/SNOBOL.
Though if you had to do enough work with text, my bet is that you'd eventually figure out why regexes won. They are simple, straightforward, and just enough to tackle the occasional matching problem on your way to doing something else.
Have you tried Parsing Expression Grammars (PEGs)? Most implementations allow use to name arbitrary sub-parsers, often using the programming language's native variables.
See for example Peg.js, LPEG (lua), etc. However, PEGs don't natively permit left recursion (note: some PEG implementations do add that on). If that's a problem, Earley parsers are a nice alternative.
Example of a calculator using Peg.js:
start
= additive
additive
= left:multiplicative "+" right:additive { return left + right; }
/ multiplicative
multiplicative
= left:primary "*" right:multiplicative { return left * right; }
/ primary
primary
= integer
/ "(" additive:additive ")" { return additive; }
integer "integer"
= digits:[0-9]+ { return parseInt(digits.join(""), 10); }I wrote a very crude library like this in VimL to make writing syntax plugins a bit easier: https://github.com/b0o/builder.vim
You can see it in use here: https://github.com/b0o/quicktemplate.vim/blob/master/syntax/...
PCRE has the DEFINE keyword. Here's an example:
https://regex101.com/library/gJ7pU0
(not to be confused with named capture groups)
There is a concept of named capturing groups:
https://regexper.com will render your regex as railroad diagram.
Maybe a help...
Look at perl6 grammars.
I'd like to see experiments in alternatives that provide this. It could help do for RegEx's what SQL's WITH statement did for long SQL statements.
Backus–Naur Form could act as a starting point, but it needs some syntactic adjustments to make it more compact and practical, in my opinion. Partial example: