Msg#: 3786530 posted 3:52 am on Nov 17, 2008 (gmt 0)
depending on your requirements, you might want to consider a few more things. - there are other sentence-ending punctuations than a period. - there are other contexts for using a period than a sentence-ending punctuation such as within a dollar amount, a url, etc.
Msg#: 3786530 posted 2:17 pm on Nov 22, 2008 (gmt 0)
Very good points. I actually had to code some fixes in to repair situations like those you mentioned. Particularly around dollar amounts and Urls. But it is definitely helping more than hurting from a formatting perspective. You would not believe how many folks type sentences without putting a space after each period. ;-)
Msg#: 3786530 posted 10:09 pm on Nov 25, 2008 (gmt 0)
Here's a Thanksgiving gift. You seem to be working hard on this problem.
s/(?<=[A-Za-z])(\.)\s*(?=[A-Z](?:[a-z]¦ ))/. /g;
This one shouldn't mess up prices or URL's (unless the URL's are mixed-case, which I don't see much of these days). It will ensure exactly one space following qualifying periods, so it will handle too many or too few.
?<= is a lookbehind assertion ?= is a lookahead assertion [A-Za-z]is a character class