Multiple substitutions in one pass

I have a long document which I am trying to parse. I am coming unstuck
trying to speed it up and get all the substitutions out the way quickly.
I have a hash array of original and new things to substitute, and it
works. However, I’m sure there is a more efficient way of doing things.
RegExp has a union method, but that doesn’t seem to handle string
capture within matches.

One final thing is that I would like this sub to throw something if no
substitutions are performed on the str.

def makeSubs(str)
subCurlyArray={/section%LCURL%(\d+)(.?)%RCURL%\1/ => “\n”+’—+\2’,
?)%RCURL%\1/ => “\n”+’—++\2’,
/subsubsection%LCURL%(\d+)(.?)%RCURL%\1/ => “\n”+’—+++\2’,
?)%RCURL%\1/ => ‘\2’,
/includegraphics[(.)]%LCURL%(\d+)(.?)%RCURL%\1/ =>‘IMAGE <img
src="\3" \2> ENDIMAGE’,
/texttt%LCURL%(\d+)(.?)%RCURL%\1/ => '\2 ',
?)%RCURL%\1/ => ‘\2’,
/textbf%LCURL%(\d+)(.?)%RCURL%\1/ => '\2*’,
/textit%LCURL%(\d+)(.*?)%RCURL%\1/ => ‘\2’,

subArray.each do |orig, new|
str.gsub!(orig, new)

return str


Thank you