CFLib.org – Common Function Library Project

uCaseWordsForSolr(string)

Last updated August 5, 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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson