There was a </CFSCRIPT>  at the bottom, must have gotten cut off.

-----Original Message-----
From: Bruce, Rodney (Contractor) [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 16, 2002 1:05 PM
To: CF-Talk
Subject: RE: Regular expression help


Here's a UDF I may not be the most eloquent but it does work.
I used it to do tile casing.  why my string is title ;o)

<CFscript>
 //Changes a String to Title case
        Function TitleCase(title){
        
                title = trim(title);
                //Caps first letter of string and Lower cases rest
                //for standardization
                    Leadchar = UCase(RemoveChars(title,2,len(title)));
                title = RemoveChars(title, 1, 1);
                title = LCase(title);
                title = Leadchar & title;
                start = 1;
                //loops through string word by word to Cap first letter
                //uses space to tell when new word starts
                While (start LT len(title)){
                        place = REFindNoCase(" ", title ,start );
                        //place has to be less than length of string 
and
                        //greater than 0 (no more words)
                        if (place LT len(title) and place GT 0){                       
         Frontpart=
Removechars(title,place,len(title));
                                backpart = RemoveChars(title, 
1,place);
                                //if last part is one letter like a 
Middle
initial
                                if (len(backpart) gt 1){                               
         nextchar=
RemoveChars(backpart,2,len(backpart));                                        backpart=
RemoveChars(backpart,1,1);
                                        nextchar = Ucase(nextchar);
                                        title = frontpart& " " & 
nextchar &
backpart;
                                start =  place +1;
                                        }
                                else{
                                        backpart = Ucase(backpart);
                                    title = frontpart &" " & 
backpart;
                                        start = place +1;
                                        }       
                                }
                        else{
                                start = len(title);
                        }
                }
                return title;
                }
        
        
        
        
                

______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to