#!c:\perl\bin\perl.exe -w use strict; use warnings; for my $line (<DATA>) { $line =~ s/ \d{4,}( |$)/ 0$1/g; print $line; } __DATA__ 1125356700 0 0 0 0 1125356400 15 0 25 0 1125356100 25 0 25 0 1125355800 25 0 25 0 1125355500 25 0 25 0 1125397800 0 0 0 0 1125397500 0 0 0 0 1125397200 0 0 0 0 1125396900 0 0 0 0 1125396600 0 0 0 0 1125396300 0 0 0 0 1125396000 39006 0 63597 0 1125395700 63597 0 63597 0 1125395400 63597 0 63597 0 1125395100 63597 0 63597 0 1125394800 63597 0 63597 0 1125394500 63597 0 63597 0 1125394200 63597 0 63597 0
Or for a one liner:
perl.exe -ple "s/ \d{4,}( |$)/ 0$1/g" filename
Update:
Oops... As cheseter has pointed out, the above will replace 1000 when it should not.
Here's my regex that works:
or at least I think it does.$line =~ s/ (\d+)/$1>1000?" 0":" $1"/ge;
In reply to Re: String Search/Replace
by ChrisR
in thread String Search/Replace
by crep
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |