• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

handling last name foramt

LEGEND ,
Mar 05, 2007 Mar 05, 2007

Copy link to clipboard

Copied

Hello, the letter that needs to be generated has a "TO" section and a person's
last name should be started with "uppercase" and rest of them is printed
"lowercase", but some cases are treated differently. (Users need to input the
last name before they generate the letter).
But they input too many different formats of last name and it is a nightmare
to catch those formt to print out the first letter to be uppercase and some
cases the second letter should also be capital..
For example, last name O'Nell. In this case, it should be print out "O" and
"N" all capital. Some has Hong-Sang.
Look at these last name that users entered.
RIVERA COLON
DAVIS JR,
KEMBALL - COOK
EARWOOD III
St. Andrews
HALL JR.
PURTILL (SMITH)
MOORE 11
COUNTRYMAN JR.,
Santos, Jr.
O NEILL
O'NEILL
omg, I have no idea how to print out thoses last name in a proper format on
"TO" section on the letter.
maybe I need to prevent them to inputting a wrong last name format, but what
are the right last name format then?
Does ColdFusion has something that can handle this situation? please advise me.




TOPICS
Advanced techniques

Views

209

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2007 Mar 05, 2007

Copy link to clipboard

Copied

LATEST
#reReplaceNoCase(put_your_var_that_holds_last_name_here,
"([[:alpha:]])((?!(\1|I|V|X){1,3}([[:space:]]|[[:punct:]])*)[[:alpha:]]*)",
"\U\1\L\2\E", "all")#

this will replace all words in a given string
(put_your_var_that_holds_last_name_here) to proper case, hyphenated
names or not, preserving Roman numerals (i.e. SMITH III, John will
become Smith III, John ; note that only certain sub-set of roman
numerals is supported...).

This one does NOT convert Mc and Mac last names correctly, though.

Credit goes to CFLib and specifically to
http://www.cflib.org/udf.cfm?ID=1384 by Jared Rypka-Hauer... i have just
modified his function a bit and added extra code to account for Roman
numerals in names...

will keep trying to incorporate Mc and Mac recognition... i know there
is another udf there for it, but i want to try to do it all in one regex
instead of a function...

--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation