in reply to Resetting pos() within a RegEx?

No loop but 2 regexps:

$_="x" x 30; s:xx:(" " x (length($')/2))."$`$&\n":ge; s:(?<=\n).*:$&$`$`:s; print;

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e