in reply to need help with search and replace

Man, no offense, but I can't read any of this. Please wrap your code in <code> tags and spell out 'and' instead of &, since you're using & both ways in different places (with and without spaces separating it from other input). Very confusing!

Perhaps if you would just give a few lines of input and a few lines of output, we could figure out how to achieve that, but your example data is inconsistent with the code below it. Specifically, "item=" v. "item1=".. Is the "& may occur often" bit part of the input or are you saying that that input may occur frequently?

I for one would work better in this case with 3 or 4 lines of example input and the 3 or 4 lines of resulting output, especially if it's just a few simple substitutions..