CFLib.org – Common Function Library Project

uCaseWordsForSolr(string)

Last updated August 05, 2011

author

Sami Hoda

Version: 1 | Requires: CF9 | Library: UtilityLib

Description:
Works with SolrClean UDF to UCASE Solr Keywords. Use in conjunction with SolrClean.

Return Values:
Returns a string.

Example:

Works in conjunction with SolrClean. See SolrClean UDF.

Parameters:

Name Description Required
string String to run against Yes

Full UDF Source:

<!---
 Works with SolrClean UDF to UCASE Solr Keywords.
 
 @param string      String to run against (Required)
 @return Returns a string. 
 @author Sami Hoda (sami@bytestopshere.com) 
 @version 1, August 5, 2011 
--->
<cffunction name="uCaseWordsForSolr" access="public" output="false" returntype="Any" >
    <cfargument name="string" type="string" default="" required="true" hint="String to run against" />
    <cfargument name="listOfWords" type="string" default="AND,OR,NOT,TO" required="false" hint="Comma-delim list of words to uCase" />

    <cfset var sLocal = StructNew() />

    <cfset sLocal.newString = lcase(arguments.string) /> <!--- lcase by default. mixed-case treated as case-sensitive by Solr --->
    <cfset sLocal.i = "" />

    <cfloop list="#arguments.listOfWords#" index="sLocal.i">

        <cfset sLocal.newString = reReplaceNoCase(sLocal.newString, "([^a-z])(#sLocal.i#)([^a-z])", "\1#ucase(sLocal.i)#\3", "all")/>

    </cfloop>

    <cfreturn sLocal.newString />
</cffunction>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson