Here is a title case custom tag that I wrote. I realized that the regular
expressions in cold fusion just aren't all as powerful as in perl. If
anyone has any suggestions on ways to optimize this even more please let me
know.
Thanks
Rich
<CFPARAM name="Attributes.original" default="">
<CFPARAM name="Attributes.searchlist" default="">
<CFPARAM name="Attributes.replacevaluelist" default="">
<CFSCRIPT>
cur_pos = 2;
new_string = Ucase(Left(Attributes.original,1));
do {
st = REFind("([[:space:]]+[[:alpha:]])",
Attributes.original, cur_pos, "TRUE" );
if ( st.pos[1] GT 0 ) {
new_string = new_string &
LCASE(Mid(Attributes.original, cur_pos, (st.pos[1]-cur_pos)));
new_string = new_string &
UCASE(Mid(Attributes.original, st.pos[1], st.len[1]));
} else {
new_string = new_string &
LCASE(Right(Attributes.original, (len(Attributes.original)-cur_pos)+1));
}
cur_pos = st.pos[1] + st.len[1];
} while ( cur_pos is NOT 0 );
if ( ListLen( Attributes.searchlist ) GT 0 ) {
new_string = ReplaceList(new_string, Attributes.searchlist,
Attributes.replacevaluelist);
}
Caller.output=new_string;
</CFSCRIPT>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists