CFLib.org – Common Function Library Project

SQLServerPatternMatchingFormat(string)

Last updated August 15, 2002

author

Matthew Walker

Version: 1 | Requires: CF5 | Library: StrLib

Description:
A visitor may enter wildcard characters into a search string without realising. An invalid search string can then produce either a database error or odd results. This is a particular problem with double-byte languages like Japanese where a [ for example may be hidden inside a character.

Return Values:
Returns a string.

Example:

"98.3%" becomes "<cfoutput>#SQLServerPatternMatchingFormat("98.3%")#</cfoutput>"

Parameters:

Name Description Required
string String to format. Yes

Full UDF Source:

/**
 * Strip pattern-matching wildcards from a string appearing in a SQL Server query.
 * 
 * @param string 	 String to format. (Required)
 * @return Returns a string. 
 * @author Matthew Walker (matthew@cabbagetree.co.nz) 
 * @version 1, August 15, 2002 
 */
function SQLServerPatternMatchingFormat(string) {
	return ReplaceList(string, "[,%,_", "[[],[%],[_]");
}
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