The following function returns the given string formatted in proper or sentence case, i.e. the first letter is upper case and the rest is in lower case. E.g: [LIST] [*]input: "roses are red", output: "Roses are red" [*]input: "c", output: "C" [*]input: "roSES ARe RED", output: "Roses are red" [/LIST] [CODE] function ProperCase(const AString: string): string; begin // make all characters into lower case Result := LowerCase(AString); // if the supplied string is not empty string, then make the first character an upper case if Result <> '' then UpCase(Result[1]) end;
2 replies to this topic
#1
Posted 20 November 2010 - 02:50 PM
|
|
|
#2
Posted 21 November 2010 - 05:43 AM
Nice bit of code :)
#3
Posted 22 November 2010 - 05:01 AM
^ Lol, thank you! Too simple of a code, I think!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









