For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2005 > Re: AW: How to remove everything after the last "." dot?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: AW: How to remove everything after the last "." dot?
Ing. Branislav Gerzo

2005-03-08, 8:56 am

Bastian Angerstein [BA], on Tuesday, March 8, 2005 at 12:19 (+0100)
wrote:

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

correct code is:

use strict;
use warnings;
my $a = 'i.like.donuts.but.only.with.tea';
$a =~ s/\.[^.]+$//;
print $a, "\n";

if you use this for domains don't forget about .co.uk and so on:)

--

...m8s, cu l8r, Brano.

[OS/2 means 2x as OutStanding as Windows]


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com