Loading ...
Sorry, an error occurred while loading the content.

4406Can a RegExp replace handle incrementing a number?

Expand Messages
  • kraemz
    Jan 9, 2006
      Hi,

      I have several XML files that I update regularly, which contain ID
      numbers in the format:

      id="22"

      I can easily isolate these instances with the regular expression:

      (id=")([0-9]+)(")

      I need to keep the id= and the quotes, and replace only the numeric
      portion (\2). The challenge is that I need to increment this number
      by 1 during the replace. So in the example, the result of the replace
      would be:

      id="23"

      I can't find any way to do this. Is it even possible, and if so, how?
      Right now I'm just searching with a RegExp similar to the above (but
      without the tagged expressions), and then double-clicking the number,
      and typing in the new value. But when there can be over 100
      replacements each time, it gets tedious fast. There's got to be a way
      around this.

      Any suggestions would be appreciated.

      Thanks,
      J
    • Show all 8 messages in this topic