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
Find/Replace + multiplication?
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
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.
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.