Learn English – “replace with” vs. “replace by” in the sense of substituting strings

grammaticalityphrasal-verbsphrasesprepositional-phrasesprepositions

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:

  1. In the next step, we replace the substring x of the string axby
    by/with y.
  2. In the next step, replace the substring x of the string axby
    by/with y.
  3. In the next step, the substring x of the string axby is replaced by/with y.
  4. We proceed by replacing the substring x of the string axby by/with y.
  5. We proceed, replacing the substring x of the string axby by/with y.
  6. The next step is to replace the substring x of the string axby by/with y.
  7. 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.

Best Answer

Both options are ambiguous, but 'with' is the better choice.

String 'x' is replaced with 'y', by the computer, using the algorithm.

'By' can refer to the 'agent' of a passive clause.
'With' can refer to an 'instrument' (tool), but 'using' is stronger.

FYI, note the ambiguity here: (because robots can be agents, patients or instruments)

Robot A was replaced with Robot B, by Robot C, using Robot D.

Robot A was replaced by Robot ___. (B or C?)

Robot A was replaced with Robot ___. (B or D?)

Related Topic