954,160 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Start of New Senetence

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?

Pgmer
Master Poster
714 posts since Apr 2008
Reputation Points: 54
Solved Threads: 121
 

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.

TeejMonster
Newbie Poster
22 posts since Jul 2009
Reputation Points: 9
Solved Threads: 2
 

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.

textbox
Light Poster
38 posts since Jul 2009
Reputation Points: 10
Solved Threads: 2
 
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 ?

Pgmer
Master Poster
714 posts since Apr 2008
Reputation Points: 54
Solved Threads: 121
 

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 ..

JadeSimon
Newbie Poster
12 posts since Aug 2009
Reputation Points: 20
Solved Threads: 5
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You