On Dec 15, 2008, at 21:53 , Johannes Plunien wrote:
My not very elegant, but working solution:
my $str = " Beta Launch Invites: Kwyno Brings The Web Into Your IM
And (Soon) SMS Inboxes ";
$str =~ s/^\s+|\s+$//g;
$str =~ s/\W/ /g;
$str =~ s/\s{1,}/ /g;
$str =~ s/\s/-/g;
$str = lc($str);
print "$str\n";
A wee bit shorter:
my $str = " Beta Launch Invites: Kwyno Brings The Web Into Your IM
And (Soon) SMS Inboxes ";
$str =~ s/^\s+|\s+$//g;
$str =~ s/\W+/-/g;
$str = lc($str);
print "$str\n";
Before putting that into a module though you might want to think about
what should happen to characters outside the [a-z0-9] range as \W will
match differently based on locale. I'm not sure what the recommended
behaviour is for such cases.
--
Robin Berjon - http://berjon.com/
Feel like hiring me? Go to http://robineko.com/
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/