Hi All
I need to capitalize the first word of each new sentence as user types. How will i come to know about the start of new sentences?
do i need to use regular expression for this?

Recommended Answers

All 4 Replies

I think that would be one way. You would have to assume that the only periods in your input are for sentence endings, not for abbreviations (st. mt. ms.) or numbers (3.14) or email addresses (john.smith@gmail.com).

Barring those annoyances, you could check for the first non-whitespace character after a period and make that a capital.

This requirement seems a bit expensive as far as processing goes. What kind of application are you creating that needs this. Maybe there is another way to handle it.

This requirement seems a bit expensive as far as processing goes. What kind of application are you creating that needs this. Maybe there is another way to handle it.

Its kind of word processor application.
any idea to achive this ?

Well obviously a period(.) indicates the end of a line. You can try it this way:

1) Check for period at the end of a word. So go word by word and check if a word ends with a period, for example "I am a VB.NET programmer." In this case we found "programmer." A word here means a series of characters without a space in between.
2) Now check if the character after the period[.] is a space. If it's a space and followed by an uppercase character then it's safe to assume the end of the line in most cases where the typing is standard.

I'm not sure if you can do this using regular expressions ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.