Hi Bastian

> Hmmm...

Aaaarrgghh!!

> use strict; use warnings;
> my $a="i.like.donuts.but.only.with.tea";
> $a=~s/\.\w+$//; # <---- maybe w+ not d+???
> print $a, "\n";

Yes, of course it should be \w, not \d !

I made it wrong in the test code, then corrected, then pasted the wrong 
version...

sorry!!


To the people who suggested 

: $a =~ s/\.[^.]+$//;

My thought to use \w and not [^.] was that I assumed (wrong, since the OP did 
not say that) the string consisting of dots and words only, and then I 
considered some input sanitizing... good intent, bad result ;-)

sorry for that too.


greetings joe

>
> Deutsche Telekom AG
> T-Com, Technische Infrastruktur Niederlassung Überregional
> Bastian Angerstein
> Network Support Center -
> Network Management Support
> Maybachstr.57; D-70469 Stuttgart
> +49 711 8939 1889 (Tel.)
> +49 711 8939 6604 (Fax)
> mailto:[EMAIL PROTECTED]
> http://www.t-com.de
>
> -----Ursprüngliche Nachricht-----
> Von: John Doe [mailto:[EMAIL PROTECTED]
> Gesendet: Dienstag, 8. März 2005 11:46
> An: beginners@perl.org
> Betreff: Re: How to remove everything after the last "." dot?
>
>
> Hi
>
> > I have a line:
> >   i.like.donuts.but.only.with.tea
> >
> > now I want to remove everything that follows the last "."
> > including the last ".".
>
> [...]
>
> you can use a regex for that.
>
> === Documentation (from command line:)
>
>
> perldoc perlre
>
> === Code:
>
> use strict; use warnings;
> my $a="i.like.donuts.but.only.with.tea";
> $a=~s/\.\d+$//; # <---- this does the trick
> print $a, "\n";
>
> # this prints:
> i.like.donuts.but.only.with.tea
>
> === explanation:
> see documentation ;-)
>
>
> greetings joe
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>

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


Reply via email to