Use the UDF: capFirstTitle()
http://www.cflib.org/udf.cfm?ID=116

For your purpose, CF RegExp won't do it as well as what Ed Hodder
implemented with his UDF.

But, FYI, REFind() and REFindNoCase() can return subexpressions.

Example:
Variables.sttREFind = REFind("[[:graph:]]+", Variables.strName, 1,
true);
If (Variables.sttREFind.pos[1] GT 0) {
        Variables.strFirstWord = Mid(Variables.strName,
Variables.sttREFind.pos[1], Variables.sttREFind.len[1]);
} else { // nothing found
        Variables.strFirstWord = "";
}

See how messy this can get? The UDF has a much more elegant solution, in
my opinion. :)

Of course, RegExp has its uses. In your case, it isn't the most optimal
solution.

James.

-----Original Message-----
From: Douglas Brown [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, January 16, 2002 12:00 PM
To: CF-Talk
Subject: Re: Regular expression help


All refind does is find the starting position of a string.

IE:

<CFSET test = REFind("^[A-Z][a-z]+", "hello world")>
<CFOUTPUT>
#test#
</CFOUTPUT>

returns "0"

I need it to change "hello world" to Hello World"




There are two major products that come out of Berkeley: LSD and [Unix] 
BSD. We don't believe this to be a coincidence.



Doug Brown
----- Original Message ----- 
From: "Douglas Brown" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, January 16, 2002 11:43 AM
Subject: Re: Regular expression help


> That definately will not do it.
> 
> 
> There are two major products that come out of Berkeley: LSD and [Unix]


> BSD. We don't believe this to be a coincidence.
> 
> 
> 
> Doug Brown
> ----- Original Message ----- 
> From: "Christopher Olive" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Wednesday, January 16, 2002 11:20 AM
> Subject: RE: Regular expression help
> 
> 
> > try
> > 
> > <CFIF REFind("^[A-Z][a-z]+", VARIABLENAME)>
> > it's capitalized!
> > </CFIF>
> > 
> > christopher olive, cto, vp of web development
> > cresco technologies, inc
> > 410.825.0383
> > http://www.crescotech.com
> > 
> > 
> > -----Original Message-----
> > From: Douglas Brown [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, January 16, 2002 1:46 PM
> > To: CF-Talk
> > Subject: Regular expression help
> > 
> > 
> > I have a field that will be populated with a first name and a last 
> name,
> > 
> > what I want to do is make sure that the first letter of the first & 
> last
> > 
> > name is uppercase and that all others are lower case. Could someone 
> help
> > 
> > in a reg expression that will do this?
> > 
> > 
> > 
> > 
> > 
> > There are two major products that come out of Berkeley: LSD and 
[Unix] 
> 
> > BSD. We don't believe this to be a coincidence.
> > 
> > 
> > 
> > Doug Brown
> > 
> > 
> 

______________________________________________________________________
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=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to