Dr.Ruud wrote:
Gunnar Hjalmarsson schreef:
danlamb:
I need a regex to remove zeros after the . in a file name if they are
followed by another digit.

Example:  XXXXXX.001  becomes XXXXXX.1

     s/\.0+(?=[1-9])/./;

That rewrites the dot, and won't handle ".000".

I would write it like

    s/(?<=\.)0+(?=[0-9])//;

Okay...

1. Why is rewriting so bad? Personally I need to look up those extended patterns, and letting the s/// operator rewrite a single dot is easier to read IMO.

2. The OP said "another" digit, which I interpreted as a non-zero digit. I may have been wrong...

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to