Find/Replace + multiplication?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
cwigley
Posts: 14
Joined: Fri Apr 21, 2006 2:48 pm
Location: New York, NY

Find/Replace + multiplication?

Post by cwigley »

I received a request to try and research the ability to do a Find/Replace, but apply some basic math on the replace. Basically, locate "X", multiply "X" by 1.2 to get "Y", replace "X" with "Y". Nothing extremely complicated, I just need to figure out the right tool for the job.

We've attempted to accomplish this in VB, but aren't getting the speed we need. I am looking into the JAVA SDK... but i don't really have any Java guys over here.

I'm just looking for a point in the most optimal direction.

Thank you for your help!

Collin
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

With a suitable scripting language you can do this on the command line with a single command. For example, if your X can be any sequence of digits, possibly containing a decimal point (regex: ([0-9]*\.)?[0-9]+ ), you can do it with perl like this:

perl -pe "s/(([0-9]*\.)?[0-9]+)/$1 * 1.2/eg" -i.bak input_file

You can do it in an editor with a scripting facility, but TextPad has no scripting facility.
Post Reply