[Pikes-peak-pm] Perl Program
Rob Nagler
nagler at bivio.biz
Sun Apr 1 20:40:40 PDT 2007
On 4/1/07, Tim Chambers <timc+perl at divide.net> wrote:
> perl -pe 's/^([^;]+[^I])([CDI]|II);/\1 \2;/' < infile > outfile
Tim's solution is fine. However, this is the perl list and there's
more than one way...
I think the following might be clearer:
perl -pe 's/(?=(?:C|D|I|II);)/ /' infile > outfile
It demonstrates some of the more powerful regexp features which only
perl seems to have. The regexp assertions (?=) are quite powerful. In this
example, they allow me to list the different part # suffixes easily so
a non-perl
programmer could easily modify this program, I think.
Rob
More information about the Pikes-peak-pm
mailing list