|
> I would like to suggest the addition of a new pattern item which will
> behave just the like the %bxy one but will return the match without
> the xy part.
...
> Does anyone else see any merit (or problem, other than the usual
> minimalism objections) in this proposal?
Every pattern can be looked at in two ways.
Yang: What does it provide under gmatch?
Yin: What does it leave behind under gsub?
Let's say your pattern will be called %B. The first question to ask is:
"Is there anything %B can do that %b cannot do, or vice versa?"
and one must look at it from both perspectives.
Under Yang it is a tie. It is just as easy to re-concatenate the delimiters
to the result of %B as it is to :sub them away from the result of %b.
Under Yin %b wins. It is easy to put two delimeters back in but you will
need to repeat the whole exercise in order to take empty balanced pairs
of them out.
I.e. if we have only one of %b and %B, then it must be %b.