• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2196
  • Last Modified:

ColdFusion: Proper Case Function?

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
hefterr
Asked:
hefterr
  • 3
  • 3
  • 2
1 Solution
 
_agx_Commented:
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
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
0
 
hefterrAuthor Commented:
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Gurpreet Singh RandhawaWeb DeveloperCommented:
like this:

<cfif str neq ucase(str)>
Incorrect
<cfelse>
Correct
</cfif>
0
 
_agx_Commented:
> <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
 
hefterrAuthor Commented:
Thanks for your help.
0
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
but agx, NEQ will work, Can you explain me better why?
0
 
_agx_Commented:
Nope, it won't. NEQ doesn't care about case so it treats "apple" and "APPLE" the same.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now