I read one explanation of the difference between replace with/by in one of the grammar books. If you are referring to replacing something that is broken, old, or not working/inoperative, then you replace it with a new one. If you are referring to filling the role of someone or something with a substitute, then it is 'replaced by' According to this rule can I use by instead of with here "Though mostly eggs are used for races, they have also been replaced in some instances with potatoes, tomatoes, lemons or synthetic eggs" ?And what variant is better/more correct? Thanks in advance!
The difference can be thought of as follows:
By: The replacement could be thought of as a causal agent. “He was replaced by her.” She (“her”) is a causal agent; she actively took his place.
With: Some third party, acting as a causal agent, replaced something with something else.
For your example, you could use either. Using “replaced by eggs” does imbue eggs with a level of autonomy that they don’t possess, but in such a formal sentence, it would be interpreted as merely a figure of speech. Also, for so many replacements over time, the third party causal agent is not really identifiable, and so “by” does make sense here.
In short, both are acceptable; “with” has the effect of identifying that there at least was a “replacer”, whereas “by”, as a figure of speech, suggest that the ingredients themselves were the “replacers”.