Here ya go...

<cfscript>
function ucasecount(str)
{
        ucount = 0;
        ufinder = refind("[A-Z]", str);
        
        while (ufinder neq 0)
        {
                ucount = ucount + 1;
                ufinder = refind("[A-Z]", str, ufinder+1);
        }
        return ucount;
}
</cfscript>

<cfset strng = "AbCdEfGhI">

<cfoutput>#ucasecount(strng)#</cfoutput>


The function returns a single numeric value. It's the number of uppercase
characters found in the string. (In the example string... 5). You could
easily add more to it such as getting the actual percent of uppercase
characters that the number represents but the easiest way would be to just
see if it's more than half the characters and do what you need to do.

Example:
<cfset tooMnayUC = len(trim(strng)) lt (ucasecount(strng)*2)>

The string is #len(strng)# characters long. Out of those #len(strng)#
characters, #ucasecount(strng)# characters are uppercase.<br><br>
Are there too many uppercase characters? <b>#tooMnayUC#</b>


 
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com

-----Original Message-----
From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] 
Sent: Sunday, October 30, 2005 11:38 AM
To: CF-Talk
Subject: RE: SHOUTING

> Maybe the Lcase function?

I don’t believe that’s what the lcase function does ;)

Just compare the strings uppercase form to its original form...
Eg: find(ucase(str), str) 

It will return 1 if the string is all uppercase, 0 if it is not...

Of course... one lowercase letter in the middle of 10000 uppercase letters
is not all uppercase though :)

You could easily write a looping function to count the number of uppercase
characters and compare that with the over all length of the string. Then you
could base your decision to allow/disallow the string on the percentage of
upper case characters vs lower case
 
Steps:
Loop over the string while #refind("[A-Z]", str, start)#. Each time #start#
will be the results of the refind()and a counter would be incremented by 1
(the counter will hold the number of uppercase characters in the end)

I've gotta run or I'd test out some actual code for you here. I'll be glad
to do I later if you want something like this but have trouble writing it.

Cheers

...:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com

-----Original Message-----
From: Webmaster at FastTrack On Line
[mailto:[EMAIL PROTECTED] 
Sent: Sunday, October 30, 2005 1:12 AM
To: CF-Talk
Subject: Re: SHOUTING

Maybe the Lcase function?

Jenny

----- Original Message ----- 
From: "Saturday (Stuart Kidd)" <[EMAIL PROTECTED]>
To: "CF-Talk" <cf-talk@houseoffusion.com>
Sent: Monday, October 24, 2005 6:02 PM
Subject: stop: SHOUTING


> Hi guys,
>
> Just wondering if anyone knows a good way to recognise when all the
> characters are capitalised?  Some users love putting text in CAPS and
> it just looks awful when it's displayed on screen.
>
> Any help I'd be grateful.
>
> Thanks,
>
> Saturday
>
>
> 





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222663
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to