Page 1 of 1

Adding same value

Posted: Fri Feb 03, 2012 2:06 pm
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?

Re: Adding same value

Posted: Fri Feb 03, 2012 2:55 pm
by rodp
Put it in excel? Hope someone else can prove it can be done in regex. Sorry I can't help further.

Rodp

Re: Adding same value

Posted: Sat Feb 04, 2012 11:33 pm
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.