1

I'm trying to multiply value in

"StackSize" Value="x"

By 3.

So all Values in x would be three times bigger. How can I do it by using mass replace?

Wesan
  • 57
  • 2
  • 7

2 Answers2

2

You cannot. Notepad++ does not have the facilities to do arithmetic in its search/replace commands. Tasks like this can be done with programming or scripting languages. For example the Perl substitution s/.../.../e could be used

Quoting from http://perldoc.perl.org/perlop.html:

A /e will cause the replacement portion to be treated as a full-fledged Perl expression and evaluated right then and there

Notepad++ has plugins that provide good support for Python and that may allow you to achieve what you want.

AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
1

There are no built-in regex-based calculation feature of this kind in Notepad++, but you may leverage the Notepad++ PythonScript plug-in.

Install it and use the following code in the script file:

def multiply_number_in_context(match):
    return "{0}{1}{2}".format(match.group(1), str(float(match.group(2))*3), '"')

editor.rereplace(r'("StackSize" Value=")(\d+)"', multiply_number_in_context)

If you plan to multiply integer values, replace float(match.group(2))*3) with int(match.group(2))*3).

Community
  • 1
  • 1
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563