replace respects commutativity
Merge pull request #7752 from smichr/nc-replace

replace respects commutativity