Adding same value

A place to try and solve your RegEx problems.
Post Reply
User avatar
Guest

Adding same value

Post by Guest »

In txt file, there are values for X, like this:
X=45
X=119
X=37
etc.

I need to add the same value, for example to add 5 so it will be:
X=50
X=124
X=42

How to do that?
rodp
Posts: 9
Joined: Thu Feb 02, 2012 5:12 pm

Re: Adding same value

Post by rodp »

Put it in excel? Hope someone else can prove it can be done in regex. Sorry I can't help further.

Rodp
User avatar
Fool4UAnyway

Re: Adding same value

Post by Fool4UAnyway »

Yes, that's what I'd do: use some program like Excel to do the _math_.

Regular expressions do not do much more than transform text or more general "characters". It does not do any calculations or the like.

You may, however, use regular expressions to split the text into columns.

Find:
([^=]+)=(\d+)

Replace by:
$1\t=\t$2

You could also replace the text in reverse order:
$2\t=\t$1

You can also just re-place only (the column with) the values: $2

Then you could copy the text and paste it into Excel in separate columns.
You could then add a column with a formula like "add 5 to the value of column 3 (or 1)".
You could re-arrange the columns in Excel, remove the source values and then use Text Crawler again to re-format the text layout.
Post Reply