Applying a series of regular expression replacements

As described in r - Automation of conversion from .Rnw to .Rmd - Stack Overflow I want to take a R no-web file and apply a series of regular expression replacements to it to create a R markdown file. Suppose that I had a vector of pairs of the form r"foo" => s"bar". What would be a good method of applying them in sequence to a String so that the value of the nth replace call becomes the first argument to the n+1st call?

Maybe a for-loop?

    r"foo" => s"baz"
    r"bar" => s"buz"
    r"buz" => s"inga"

function do_replace(s)
    for rs in REPLACEMENTS
        s = replace(s, rs)
    return s
julia> do_replace("foobar")
1 Like

Thanks. That is more-or-less the approach I settled on.