Open
Description
Consider this script:
def add_1(m):
z = int(m.group(1))
return 'Y' + str(z + 1) if z < 100 else m.group(0)
# replace X followed by numbers by an incremented number
# e.g. X999
# e.g. X56 X39
# e.g. X999
# e.g. X56 X39
# e.g. X999
# e.g. X56 X39
# becomes
# Y57 Y40 Y1000
editor.rereplace('X([0-9]+)', add_1);
Running this script upon its own source file tab results in:
Note that lines 7, 9, 11 have the change-history modified marker, even though the text on this lines is the same as it was before the script was run and the replacements made.
Ideally the text that isn't changed wouldn't be replaced and the result after the replacement would look like this:
Using PS2.0 and PS3.10.4.