in reply to Re: Stuck in komplexer regex, at least for me
in thread Stuck in komplexer regex, at least for me
Hi, You need an anchor '^' to make sure the matchings start from the beginning of your strings..and your requirements might be written into two patterns which would be much easier to understand(the order of two s/// expressions matters)..
Xicheng
#!/usr/bin/perl use warnings; use strict; while(<DATA>) { s/^(\d\d[1-9])0(?=[1-9])/$1/; s/^(\d\d(?:[1-9]0)?)0+/$1/; print; } __DATA__ 215000007801 300000324002 890000457651 210004563401 201045139158Regards,
Xicheng
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Stuck in komplexer regex, at least for me
by ultibuzz (Monk) on Mar 27, 2007 at 06:42 UTC |
In Section
Seekers of Perl Wisdom