in reply to Re: String Search/Replace
in thread String Search/Replace

{4,} is greedy, so the ( |$) is not needed. The following is sufficient, shorter and faster:

perl -ple "s/ \d{4,}/ 0/g" infile >outfile

Replies are listed 'Best First'.
Re^3: String Search/Replace
by ChrisR (Hermit) on Aug 31, 2005 at 15:49 UTC
    Thanks. I didn't think about that. I've never been very good at golf (perl or otherwise).
Re^3: String Search/Replace
by Roy Johnson (Monsignor) on Aug 31, 2005 at 16:10 UTC
    The -l is unnecessary, too.

    Caution: Contents may have been coded under pressure.