Given that both prepositions are acceptable in general contexts with a slight deviation in usage, meaning, and voice ("Replace with" versus "replace by" has a too wide scope), let us narrow the task down semantically and vary only the form of "replace". Here, we are going to speak only about replacing in the sense of substituting substrings of strings by/with other substrings.
The following sentences in question are short versions of somewhat more complicated sentences taken from the description of some algorithm. The sentences have been uniformized to abstract from irrelevant algorithm details:
- In the next step, we replace the substring x of the string axby by/with y.
- In the next step, replace the substring x of the string axby by/with y.
- In the next step, the substring x of the string axby is replaced by/with y.
- We proceed by replacing the substring x of the string axby by/with y.
- We proceed, replacing the substring x of the string axby by/with y.
- The next step is to replace the substring x of the string axby by/with y.
- The next step is the replacement of the substring x of the string axby by/with y.
(If anyone is interested: if x occurs neither in a nor in by, the result of the replacement will be ayby.)
How would you formulate the sentences 1–7 and why?
As an aside, notice that the passive form 3 has no agent.
As another aside, if anyone is interested, the algorithm itself has the form
[
Input: some string
Output: some other string
- do foo
- do bar
- do bla
]
I have several options of how to write down the "do xxx" parts using any style in the range 1–7. Moreover, a few versions of the algorithm are scattered around the paper. The paper is going to be submitted to a serious computer science venue.