I'm looking for a function to convert a string of text that is in UpperCase to SentenceCase. All the examples I can find turn the text into TitleCase.
Sentence case in a general sense describes the way that capitalization is used within a sentence. Sentence case also describes the standard capitalization of an English sentence, i.e. the first letter of the sentence is capitalized, with the rest being lower case (unless requiring capitalization for a specific reason, e.g. proper nouns, acronyms, etc.).
Can anyone point me in the direction of a script or function for SentenceCase?
There isn't anything built in to .NET - however, this is one of those cases where regular expression processing actually may work well. I would start by first converting the entire string to lower case, and then, as a first approximation, you could use regex to find all sequences like
[a-z]\.\s+(.), and useToUpper()to convert the captured group to upper case. TheRegExclass has an overloadedReplace()method which accepts aMatchEvaluatordelegate, which allows you to define how to replace the matched value.Here's a code example of this at work:
This could be refined in a number of different ways to better match a broader variety of sentence patterns (not just those ending in a letter+period).