Solved

ColdFusion: Proper Case Function?

Posted on 2013-01-28
8
1,528 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 500 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 15

Expert Comment

by:myselfrandhawa
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
 
LVL 15

Expert Comment

by:myselfrandhawa
ID: 38831621
like this:

<cfif str neq ucase(str)>
Incorrect
<cfelse>
Correct
</cfif>
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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 15

Expert Comment

by:myselfrandhawa
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now