I have a large amount of text in the following format:
EC,090610,170000,01395.60,1
The next to the last element in this comma-delimited series (01395.60) needs to have the leading zero stripped away, and the number needs to be divided by 1,000 to yield 1.3560. The final result should be five digits, one digit before the decimal and four after the decimal.
Is it possible to perform this transformation with a regular expression?
Thank you.
Find and Replace with Decimal Numbers
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Is the first digit always a zero?
Is it acceptable to remove the last digit instead of rounding it properly?
(TextPad's regex search and replace does not support arithmetic, so performing arithmetic, where it is possible at all, can be tedious.)
If so:
Is it acceptable to remove the last digit instead of rounding it properly?
(TextPad's regex search and replace does not support arithmetic, so performing arithmetic, where it is possible at all, can be tedious.)
If so:
This assumes you are using Posix regular expression syntax:Find what: 0([0-9])([0-9]{3})\.([0-9])[0-9]*,([^,]*)$
Replace with: \1.\2\3,\4
[X] Regular expression
Replace All
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax