How do you save a complex regex for multiple reuse in sed?
You can use shell variables:
complicated_regex='(([a-f0-9]{32})+([a-zA-Z0-9=]{{$i}})?)+'
sed s/^"$complicated_regex":"$complicated_regex"\$/'simple-output'/ my_file
I'm not sure about what you meant by $i
, but you might need to put it outside single quotes:
complicated_regex='(([a-f0-9]{32})+([a-zA-Z0-9=]{{'"$i"'}})?)+'