SmarterProper ( inText; prevCase; textSoFar; prefixList )
Rate this function: Average rating: 2.2 (201 votes) Discuss this Custom Function
David Tremmel, Duke University
http://www.duke.edu
Similar to the Proper function, but handles names with prefixes better
Sample Input:
| SmarterProper ( "MACDONALD"; 2; ""; "Mc¶Mac" ) |
|
Sample Output:
|
Description:
** UPDATED on 6/15/09 to:
(1) really fix a bug affecting formatting around apostrophes
(2) fix a bug that gave incorrect results if there were multiple spaces between words
**
** UPDATED on 6/3/08 to:
(1) fix a bug affecting formatting around apostrophes
(2) add the ability to capitalize after hyphens
(3) add the ability to specify that the word start with a lowercase letter
**
SmarterProper is designed to handle names better than the standard Proper function. It returns text with the first letter of each word capitalized - like Proper does - but unlike Proper, it also:
(1) keeps any letters in the middle of words capitalized (if they were preceeded by a lowercase character in the original);
(2) capitalizes letters after an apostrophe (for names like O'Malley) - but only if the remaining text is longer than one character (to correctly format words like Didn't and It's);
(3) capitalizes the first letter of the second part of a hyphenated name;
(4) capitalizes letters after any prefixes you specify (e.g., Mc, Mac).
Syntax: SmarterProper( inText; prevCase; textSoFar; prefixList )
inText = the original text
prevCase = a number representing the case of the preceeding character (for recursion); it should be set to 2 to capitalized the first character of the text, or 0 if you want the first character of the text to be lowercase
textSoFar = the text string at this piont in the recursion; it should be set to empty when the function is called
prefixLIst = list of prefixes that should be followed by a capital letter (a return-delmiited list)
Examples:
SmarterProper ( "MACDONALD"; 2; ""; "Mc¶Mac" ) returns MacDonald
SmarterProper ( "LaMond"; 2; ""; "Mc¶Mac" ) returns LaMond (rather than Lamond)
SmarterProper ( "o'shea"; 2; ""; "Mc¶Mac" ) returns O'Shea
SmarterProper ( "SMITH-THOMAS"; 2; ""; "Mc¶Mac" ) returns Smith-Thomas
Note: these functions are not guaranteed
or supported by BrianDunning.com. Please contact the individual
developer with any questions or problems.
This is my Custom Function and I want to
edit it
Discuss:Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:
|
Newest Custom Functions:
| 1. |
phpArrayValue ( array ; key ; pos ) |
| |
(Fri, Jan 27, 1:49pm) |
| 2. |
solfm_timeToMinutes (theTime;roundSec) |
| |
(Fri, Jan 20, 6:26am) |
| 3. |
filterLines(filterField;filterValue;Result) |
| |
(Sat, Jan 14, 2:20pm) |
| 4. |
getMaxValue ( theList ) |
| |
(Thu, Jan 12, 1:06pm) |
| 5. |
MiddleWordsIncPunct ( text ; startingWord ; numberOfWords ) |
| |
(Sat, Jan 07, 9:16am) |
| 6. |
WindowInfo |
| |
(Fri, Jan 06, 12:39pm) |
| 7. |
CenterWindow in Window vert horiz (demension) |
| |
(Fri, Jan 06, 12:25pm) |
| 8. |
UTF8_to_TXT ( Text , Platform ) |
| |
(Wed, Dec 28, 10:44pm) |
 |
|
Does anyone review the reviews to catch SPAMM?
Lee Smith, Woodland
August 13, 2010 5:12pm