in reply to regexp on utf8 string
The good thing about functions such as ucfirst is that they're locale-friendly. You don't really have to worry about what upper-case characters map to what lower-case characters in a given character set; ucfirst knows. Try this:
my $string = "word1 word2 word3"; $string = join ' ', map { ucfirst } split /\s+/, $string;
It ought to do the trick. ...just one way to do it.
A slightly more robust regexp solution might include the following:
use strict; use warnings; my $string = "word1 word2 word3"; $string =~ s/(\w+)(?=\W|$)/ucfirst $1/eg;
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regexp on utf8 string
by fredvdv (Novice) on Sep 12, 2004 at 16:31 UTC |