in reply to Re^2: substr function
in thread substr function

Then write your own implementation of substr instead of replacing it. Most likely you'll need to write a parser for whatever language you're parsing. It shouldn't be hard, and "replace substr" clutters your problem with many hard (and weird) problems that are unrelated to the task.