?
Solved

ColdFusion: Proper Case Function?

Posted on 2013-01-28
8
Medium Priority
?
1,893 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

 
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

Quick Cloud Training

Looking for some quick training on the cloud in 2 hours or less? Check out these how-to guides in AWS, Linux, OpenStack, Azure, and more!

Question has a verified solution.

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

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, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 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