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

4407Re: [edit+] Can a RegExp replace handle incrementing a number?

Expand Messages
  • Mark Kahn
    Jan 9, 2006
      No, this isn't possible with straight RegEx's. If you want to do this,
      you'd have to write your own tool to do it.

      If you know JavaScript, you can use my Range Parsing code as a start and go
      from there:

      http://www.editplus.info/wiki/User_Tools#Parse_1-n_ranges_into_text.2C_ie_.5B0-9.5D

      -Mark

      On 1/9/06, kraemz <jkraemer@...> wrote:
      >
      > 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
      >
      >
      >
      >
      >
      >
      >
      >
      > http://www.editplus.com
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Show all 8 messages in this topic