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, "[,%,_", "[[],[%],[_]");
}

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