Regular Expression help

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
 
M

Martin Honnen

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()));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top