Fix issue 12890 - index based replace