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

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

Expand Messages
  • kraemz
    Jan 10, 2006

      Thanks for replying. I've had a look at your example, and can follow
      it part way, however I've become confused. Do you happen to have any
      documentation on what it is doing, or at least a commented version of
      the code? In particular, the use of recursion in this example makes
      following the flow a bit complicated (for me, anyway) without some
      sort of explanation.

      From my testing, your code seems to output all unmatched (non-range)
      text it encounters in the input file once for every individual range
      value. Just as an experiment, and knowing it wasn't going to do what
      I needed right away, I tried your original code as a filter using my
      XML file as input, and even though it did not find any ranges, it
      made the file about 150 times longer than it was before. I would have
      expected it would simply output the file unchanged if it didn't find
      any matches.

      If, as you have said, I must address my "find/replace with increment"
      issue by using a text filter similar to yours, what it needs to do is
      to read the XML file (easy enough), identify the id values
      (straightforward using my RegExp), increment the id values (simple
      addition), then write everything back the way it was, except for the
      id values which were updated (not immediately obvious how to achieve

      I've been able to get part way by editing your example, but figure I
      could spend days trying to sort it all out. If you would be willing
      to provide some documentation, I'll have a better shot at determining
      which parts of it are relevant for what I need. I'm hoping that once
      I get my head around your algorithm, mine will turn out to be a
      simplified version.

    • Show all 8 messages in this topic