Skip to content Skip to sidebar Skip to footer

Notepad++ Regex + Python Script (addition In The Replace)

I got quite the same problem of this guy 'Notepad++ Regular Expression add up numbers' i don't know python (shame on me maybe). I got an array : $_ArrFinal = array('A'=>1, 'B' =

Solution 1:

It seems that the default Python Script installation is not working well. This is what has just worked for me:

  • Install Python Script 1.0.8.0
  • Go to the Plugins -> Python Script -> New Script
  • Select the file name (say, "increment_numbers.py")
  • Place this script there:

Code:

defcalculate(match):
    return'%s%s'%(match.group(1), str(int(match.group(2))+1))

editor.rereplace(r'(=>\s*"?)(\d+)', calculate)

Then, just evoke this 'increment_numbers' script.

See the regex demo. The expression matches:

  • (=>\s*"?) - Group 1, => followed with zero or more whitespace symbols (\s*) followed with an optional " (as ? matches one or zero preceding token)
  • (\d+) - Group 2, one or more digits

Post a Comment for "Notepad++ Regex + Python Script (addition In The Replace)"