O
Omega
Hi all
I use Regex.Replace to capitalize files name. Here is the code:
-----------------------------
static string CapitalizeText(string s)
{
return Regex.Replace(s, @"\w+", new
MatchEvaluator(CapitalizeText));
}
static string CapitalizeText(Match m)
{
string x = m.ToString();
if (char.IsLower(x[0]))
{
return char.ToUpper(x[0]) + x.Substring(1, x.Length-1);
}
return x;
}
-------------------------------------
if I call:
CapitalizeText("laura pausini - it's not goodbye.mp3")
I'll get "Laura Pausini - It'S Not Goodbye.Mp3", as you see, the uppercase
of 'S' in 'It's' is not so nice, how can I prevent this (by modify the
expression "\w+") ?
Thankyou
I use Regex.Replace to capitalize files name. Here is the code:
-----------------------------
static string CapitalizeText(string s)
{
return Regex.Replace(s, @"\w+", new
MatchEvaluator(CapitalizeText));
}
static string CapitalizeText(Match m)
{
string x = m.ToString();
if (char.IsLower(x[0]))
{
return char.ToUpper(x[0]) + x.Substring(1, x.Length-1);
}
return x;
}
-------------------------------------
if I call:
CapitalizeText("laura pausini - it's not goodbye.mp3")
I'll get "Laura Pausini - It'S Not Goodbye.Mp3", as you see, the uppercase
of 'S' in 'It's' is not so nice, how can I prevent this (by modify the
expression "\w+") ?
Thankyou