supposing I have something like that:
echo "bLah BLaH blAH" | sed -r 's/([a-zA-Z ]+)/\L&; s/[a-z]/\u&/g'
Quite a typical use for sed to get a "crazy-case" string into mixed case (first letter uppercase, rest of letters lowercase)
However, this will always affect the WHOLE string. If I, for instance, want to parse "crazy" mp3 filenames in various flavors ($tracknr - $artist - $title vs. $artist - $tracknr - $title) things get way more complicated, because sometimes titles are in foreign languages like French and mixed case just looks BUTT-UGLY in French or Italian. That's why I only want to proceed until some delimiter is reached, e. g. space-dash-space.
Hence, I'd like to use combined 's/.../...' expressions to do things step by step. However, it would be nice to have a way to "store" subexpressions from PREVIOUS expressions, to make me able to use preserved sub-matches as source expressions for the next sed replace expression.
If you think that works OOTB anyhow, you're wrong. You simply CANNOT use '\1' syntax in the second expression after the semicolon to refer to the previous expression's subexpression (of course it works once you have defined a subexpression in the second expression itself, but this possibility not be considered now). In my case, is just unknown to the parser, and you'll get the error
sed: -e expression #1, char (xx): invalid reference \1 on `s' command's RHS
Is there anything implemented to perform that sort of thing?