Regular Expression help

  • Thread starter Thread starter Lucky
  • Start date Start date
L

Lucky

Hi Guys,
I'm trying to figure out how the regular expressions are working in C#
3.0.

I've a string:

Hi! i am Bus driver.

i need to make first character of each letter to Upper Case. the
output should be like this:

output:

Hi! I Am Bus Driver

as i've a long text to search and replace i chose regular expression
to do the operation. I tried to do so but i couldnt figured out how to
do that.

I would appreciate any help on this.

Thanks
 
Lucky said:
Hi Guys,
I'm trying to figure out how the regular expressions are working in C#
3.0.

I've a string:

Hi! i am Bus driver.

i need to make first character of each letter to Upper Case. the
output should be like this:

output:

Hi! I Am Bus Driver

as i've a long text to search and replace i chose regular expression
to do the operation. I tried to do so but i couldnt figured out how to
do that.

Here is an example that uses the Regex.Replace method with a match
evaluator expressed as a lamba expression to replace the first letter
following a word boundary with its upper case representation:

Console.WriteLine(Regex.Replace("Hi! i am Bus driver.",
@"\b(\w)", m => m.Captures[0].Value.ToUpper()));
 
Back
Top