Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ColdFusion: Proper Case Function?

Posted on 2013-01-28
8
Medium Priority
?
1,974 Views
Last Modified: 2013-01-29
Hi,
I was wondering if someone could point me to a solid UDF, UDT or CFC that takes a string of "words" and converts them into proper "title case".  This is where
-  the first letter of each word is uppercase
-  rest of each word is lower case
-  does not capitalize words that are prepositions, articles (you know - the small connector words)
-  Handles some common abbreviations?

You know what I mean (I hope).

Thanks in advance,
hefterr
0
Comment
Question by:hefterr
  • 3
  • 3
  • 2
8 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 38828836
This is not really an answer, but .. :) with stuff like that I always check cflib.org first. CapFirstTitle might do some of what you need. I highly doubt it'll do everything (like exclude all "prepositions" and "abbreviations"), but maybe you can customize it.
0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 38829929
0
 
LVL 1

Author Comment

by:hefterr
ID: 38831567
The CapFirstTitle is close to what I am looking for.  Just one more related question.  How does one test a string in CF to see if the alphabetic characters are all upper case?  It's related because I beleive this is why my boss wants to use this function.
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 38831621
like this:

<cfif str neq ucase(str)>
Incorrect
<cfelse>
Correct
</cfif>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38831802
> <cfif str neq ucase(str)>

Not quite. NEQ is case *insensitive*

You can either use a regex or compare() the string to the upper case version (compare is case sensitive)

      <cfif compare( someString, ucase(someString)) eq 0>
            all upper case
      <cfelse>
            NOT all upper case
      </cfif>
0
 
LVL 1

Author Closing Comment

by:hefterr
ID: 38831867
Thanks for your help.
0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 38832455
but agx, NEQ will work, Can you explain me better why?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38832545
Nope, it won't. NEQ doesn't care about case so it treats "apple" and "APPLE" the same.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question