Wont a simple LCASE() do and then 

function CapFirst(str) {
        var newstr = "";
        var word = "";
        var i = 1;
        var strlen = listlen(str," ");
        for(i=1;i lte strlen;i=i+1) {
                word = ListGetAt(str,i," ");
                newstr = newstr & UCase(Left(word,1));
                if(len(word) gt 1) newstr = newstr &
Right(word,Len(word)-1);
                if(i lt strlen) newstr = newstr & " ";
        }
        return newstr;
}

That's whats in our function....I think its from CFLIB....


-----Original Message-----
From: Paul Johnston [mailto:[EMAIL PROTECTED] 
Sent: 27 May 2004 14:40
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] Regex to capitalise first letter of every word in a
sentence.

Stephen,

I'm not sure it's possible!  The only way I could think of doing it, is by
providing 26 regular expressions... ie:

rereplace(rereplace(string, " a", " A", "all"), " b", " B", "all") etc...

I don't think this will be as effective as putting the thing into an array
and then belting it out like this:

<!--- WARNING - UNTESTED CODE --->
<cfset strarray = listtoarray(string, " ")> <cfset newstr = ""> <cfloop
from="1" to="#arraylen(strarray)#" index="i">
    <cfset newstr = ucase(left(strarray[i], 1)) & right(strarray[i],
len(strarray[i]) - 1) & " ">
</cfloop>
<cfset newstr = trim(newstr)>

I don't really see any bettter way tbh

Paul

Stephen Moretti wrote:

> Adrian Lynch wrote:
>
>> http://www.cflib.org/udf.cfm?ID=889
>>
>> I have one that's faster somewhere but cflib didn't put it up for 
>> some reason, see what you think of that one though, cfscript based.
>>
>>  
>>
>
> Cheers guys.....  I was kinda trying to be a smart alex and avoid the 
> whole looping the space delimited list lark.
>
> I'll probably just go with your udf Adrian, cos its too hot in this 
> office to be starting thinking about regex. ;o)
>
> Stephen.
>
>


--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
 
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided
by activepdf.com*
      *Forums provided by fusetalk.com* :: *ProWorkFlow provided by
proworkflow.com*
           *Tutorials provided by helmguru.com* :: *Lists hosted by
gradwell.com*

To unsubscribe, e-mail: [EMAIL PROTECTED]
This e-mail is from Reed Exhibitions (Oriel House, 26 The Quadrant,
Richmond, Surrey, TW9 1DL, United Kingdom), a division of Reed Business,
Registered in England, Number 678540.  It contains information which is
confidential and may also be privileged.  It is for the exclusive use of the
intended recipient(s).  If you are not the intended recipient(s) please note
that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful.  If you have
received this communication in error please return it to the sender or call
our switchboard on +44 (0) 20 89107910.  The opinions expressed within this
communication are not necessarily those expressed by Reed Exhibitions.
Visit our website at http://www.reedexpo.com

-- 
These lists are syncronised with the CFDeveloper forum at 
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
 
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by 
activepdf.com*
      *Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
           *Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*

To unsubscribe, e-mail: [EMAIL PROTECTED]

Reply via email to