- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- CSVRead
- CSVWrite
- CSVProcess
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetCSPNonce
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPropertyString
- GetPropertyFile
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- Generate3DesKey
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InterruptThread
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- isThreadInterrupted
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListGetDuplicates
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetPropertyString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- StreamingSpreadsheetNew
- StreamingSpreadsheetCleanup
- StreamingSpreadsheetRead
- StreamingSpreadsheetProcess
- SpreadsheetSetFooterImage
- SpreadsheetSetHeaderImage
- SpreadsheetSetFittoPage
- SpreadsheetUngroupColumns
- SpreadsheetGroupColumns
- SpreadsheetUngroupRows
- SpreadsheetGroupRows
- SpreadsheetRemoveColumnBreak
- SpreadsheetSetColumnBreak
- SpreadsheetRemoveRowBreak
- SpreadsheetSetRowBreak
- SpreadsheetRemovePrintGridlines
- SpreadsheetAddPrintGridlines
- SpreadsheetGetColumnWidth
- SpreadsheetSetColumnHidden
- SpreadsheetSetRowHidden
- SpreadsheetisColumnHidden
- SpreadsheetisRowHidden
- SpreadsheetisStreamingXmlFormat
- SpreadsheetisXmlFormat
- SpreadsheetisBinaryFormat
- SpreadsheetRenameSheet
- SpreadsheetRemoveSheetNumber
- SpreadsheetGetLastRowNumber
- SpreadsheetGetPrintOrientation
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StructValueArray
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- cfcache
- cfcalendar
- cfcase
- cfcatch
- cfchart
- cfchart tag in ColdFusion
- Get started with cfchart
- Customize a chart using cfchart
- Advanced cfchart customization options
- Create an area chart in ColdFusion
- Create line charts in ColdFusion
- Create bar charts in ColdFusion
- Create floating bar charts in ColdFusion
- Create histograms in ColdFusion
- Create pie charts in ColdFusion
- Create funnel charts in ColdFusion
- Create pyramid charts in ColdFusion
- Create curve charts in ColdFusion
- Create boxplots in ColdFusion
- Create donut charts in ColdFusion
- Create bubble charts in ColdFusion
- Create scatterplots in ColdFusion
- Create radar charts in ColdFusion
- Other chart types in ColdFusion (Cone, Cylinder, Piano, and Bullet)
- Advanced customization options in cfchart
- cfchartdata
- cfchartseries
- cfchartset
- cfclient
- cfclientsettings
- cfcol
- cfcollection
- cfcomponent
- cfcontent
- cfcontinue
- cfcookie
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Finds the first occurrence of a substring in a string, from a specified start position. If substring is not in string , returns zero. The search is case-insensitive.
Returns
The position of substring in string ; or 0, if substring is not in string .
Category
Function syntax
FindNoCase(substring, string [, start ]) |
See also
Find, CompareNoCase, FindOneOf, REFind, Replace
Parameters
Parameter |
Description |
|---|---|
substring |
A string or a variable that contains one. String for which to search. |
string |
A string or a variable that contains one. String in which to search. |
start |
Start position of search. |
Example
In the following example, the Find function returns 33 as the first position found because "the" is lowercase. The FindNoCase function returns 1 as the first position because the case is ignored.
<cfset stringToSearch = "The quick brown fox jumped over the lazy dog.">
stringToSearch = <cfoutput>#stringToSearch#</cfoutput><br>
<p>
Find Function:<br>
Find("the",stringToSearch) returns <cfoutput>#find("the",stringToSearch)#</cfoutput><br>
<p>
FindNoCase Function:<br>
FindNoCase("the",stringToSearch) returns <cfoutput>#FindNoCase("the",stringToSearch)#</cfoutput>
Real-world use cases of the FindNoCase function
Product search
eCommerce site where customers search for products using various capitalizations.
<cfscript>
// Product database simulation
products = [
{id: 1, name: "Apple iPhone 15 Pro", category: "Electronics"},
{id: 2, name: "Samsung Galaxy S24", category: "Electronics"},
{id: 3, name: "MacBook Pro 16-inch", category: "Computers"},
{id: 4, name: "iPad Air 5th Generation", category: "Tablets"},
{id: 5, name: "AirPods Pro 2nd Gen", category: "Audio"}
];
// User search queries in different cases
searchQueries = ["iphone", "SAMSUNG", "macbook", "AirPods", "pro"];
writeOutput("<h2>Product Search Results</h2>");
for (query in searchQueries) {
writeOutput("<h3>Search: '" & query & "'</h3>");
foundProducts = [];
for (product in products) {
// Case-insensitive search in product name
if (FindNoCase(query, product.name) > 0) {
// Also check position for highlighting
position = FindNoCase(query, product.name);
arrayAppend(foundProducts, {
product: product,
position: position
});
}
}
if (arrayLen(foundProducts) > 0) {
writeOutput("<ul>");
for (found in foundProducts) {
// Highlight the found term in the product name
productName = found.product.name;
highlightedName = replace(productName, mid(productName, found.position, len(query)),
"<mark>" & mid(productName, found.position, len(query)) & "</mark>", "one");
writeOutput("<li>" & highlightedName & " - " & found.product.category & "</li>");
}
writeOutput("</ul>");
} else {
writeOutput("<p><em>No products found</em></p>");
}
}
</cfscript>
User permission system
Security system checking user roles and permissions regardless of how they're stored in different systems. User roles come from various systems (LDAP, databases, config files) with inconsistent capitalization. Security checks must work regardless of case.
<cfscript>
// User data from different sources with inconsistent casing
users = [
{username: "john.smith", roles: "Admin,Editor,Viewer"},
{username: "jane.doe", roles: "EDITOR,viewer"},
{username: "bob.jones", roles: "Viewer"},
{username: "alice.wong", roles: "admin,MODERATOR,editor"}
];
// Permission requirements (case variations common in config files)
requiredPermissions = [
{resource: "user_management", requiredRole: "admin"},
{resource: "content_editing", requiredRole: "editor"},
{resource: "view_reports", requiredRole: "viewer"},
{resource: "moderate_content", requiredRole: "moderator"}
];
function hasPermission(userRoles, requiredRole) {
// Case-insensitive role checking
return FindNoCase(requiredRole, userRoles) > 0;
}
writeOutput("<h2>User Access Control Report</h2>");
writeOutput("<table border='1' cellpadding='8'>");
writeOutput("<tr><th>User</th><th>Roles</th><th>User Management</th><th>Content Editing</th><th>View Reports</th><th>Moderate Content</th></tr>");
for (user in users) {
writeOutput("<tr>");
writeOutput("<td>" & user.username & "</td>");
writeOutput("<td>" & user.roles & "</td>");
// Check each permission
for (permission in requiredPermissions) {
if (hasPermission(user.roles, permission.requiredRole)) {
writeOutput("<td style='color: green; text-align: center;'>✅</td>");
} else {
writeOutput("<td style='color: red; text-align: center;'>❌</td>");
}
}
writeOutput("</tr>");
}
writeOutput("</table>");
// Detailed permission analysis
writeOutput("<h3>Permission Analysis</h3>");
for (user in users) {
//writeOutput("<div style='margin: 10px; padding: 10px; border: 1px solid #ccc;'>");
writeOutput("<strong>" & user.username & "</strong><br>");
for (permission in requiredPermissions) {
position = FindNoCase(permission.requiredRole, user.roles);
if (position > 0) {
writeOutput("• Can access <strong>" & permission.resource & "</strong> ('" &
permission.requiredRole & "' found at position " & position & ")<br>");
}
}
writeOutput("</div>");
}
</cfscript>
Email domain filtering system
Corporate email system filtering and routing emails based on domain patterns. Email domains can appear in various cases due to different mail servers and user input. Security filtering must be case-insensitive to be effective.
<cfscript>
// Incoming emails with mixed case domains (real-world scenario)
incomingEmails = [
{from: "support@MICROSOFT.COM", subject: "License renewal notice"},
{from: "noreply@github.com", subject: "Pull request merged"},
{from: "alerts@AWS.Amazon.com", subject: "Service health notification"},
{from: "team@SALESFORCE.org", subject: "Meeting invitation"},
{from: "suspicious@tempmail.NET", subject: "You won a prize!"},
{from: "admin@company-internal.com", subject: "Internal memo"}
];
// Email filtering rules
trustedDomains = ["microsoft.com", "github.com", "amazon.com", "salesforce.com"];
suspiciousDomains = ["tempmail", "10minutemail", "guerrillamail", "throwaway"];
internalDomains = ["company-internal.com", "corp.local"];
function checkEmailSecurity(emailAddress) {
result = {
status: "unknown",
reason: "",
action: "review"
};
// Check for trusted domains (case-insensitive)
for (domain in trustedDomains) {
if (FindNoCase(domain, emailAddress) > 0) {
result.status = "trusted";
result.reason = "From trusted domain: " & domain;
result.action = "allow";
return result;
}
}
// Check for suspicious domains
for (suspicious in suspiciousDomains) {
if (FindNoCase(suspicious, emailAddress) > 0) {
result.status = "suspicious";
result.reason = "Contains suspicious pattern: " & suspicious;
result.action = "block";
return result;
}
}
// Check for internal domains
for (internal in internalDomains) {
if (FindNoCase(internal, emailAddress) > 0) {
result.status = "internal";
result.reason = "Internal domain: " & internal;
result.action = "priority";
return result;
}
}
return result;
}
writeOutput("<h2>Email Security Filtering</h2>");
writeOutput("<table border='1' cellpadding='8'>");
writeOutput("<tr><th>From</th><th>Subject</th><th>Status</th><th>Reason</th><th>Action</th></tr>");
for (email in incomingEmails) {
security = checkEmailSecurity(email.from);
// Color coding based on status
statusColors = {
"trusted": "green",
"internal": "blue",
"suspicious": "red",
"unknown": "orange"
};
statusColor = statusColors[security.status] ?: "black";
writeOutput("<tr>");
writeOutput("<td>" & email.from & "</td>");
writeOutput("<td>" & email.subject & "</td>");
writeOutput("<td style='color: " & statusColor & ";'><strong>" & UCase(security.status) & "</strong></td>");
writeOutput("<td>" & security.reason & "</td>");
writeOutput("<td><strong>" & UCase(security.action) & "</strong></td>");
writeOutput("</tr>");
}
writeOutput("</table>");
// Statistics
stats = {trusted: 0, suspicious: 0, internal: 0, unknown: 0};
for (email in incomingEmails) {
security = checkEmailSecurity(email.from);
stats[security.status]++;
}
writeOutput("<h3>Filtering Statistics</h3>");
writeOutput("<ul>");
for (status in stats) {
writeOutput("<li>" & UCase(status) & ": " & stats[status] & " emails</li>");
}
writeOutput("</ul>");
</cfscript>
System configuration parser
Server configuration system reading settings from various config files with inconsistent formatting. Configuration files often have inconsistent naming conventions (snake_case, UPPER_CASE, camelCase). Case-insensitive parsing ensures all valid settings are found regardless of formatting style.
<cfscript>
// Configuration files from different sources
configSources = [
{
source: "main.conf",
content: "DATABASE_HOST=localhost; CACHE_ENABLED=true; DEBUG_MODE=false; SSL_REQUIRED=TRUE"
},
{
source: "environment.conf",
content: "database_port=3306; cache_timeout=300; Debug_Level=INFO; ssl_certificate=/path/to/cert"
},
{
source: "user.conf",
content: "Max_Connections=100; Connection_Pool=enabled; backup_enabled=YES; SSL_Port=443"
}
];
// Configuration parser
function parseConfig(configContent, settingName) {
result = {
found: false,
value: "",
position: 0
};
// Look for setting name (case-insensitive)
position = FindNoCase(settingName, configContent);
if (position > 0) {
result.found = true;
result.position = position;
// Find the equals sign after the setting name
equalsPos = find("=", configContent, position);
if (equalsPos > 0) {
// Find the end of the value (semicolon or end of string)
semicolonPos = find(";", configContent, equalsPos);
if (semicolonPos == 0) {
semicolonPos = len(configContent) + 1;
}
// Extract and clean the value
result.value = trim(mid(configContent, equalsPos + 1, semicolonPos - equalsPos - 1));
}
}
return result;
}
// Settings to look for
requiredSettings = [
"database_host",
"cache_enabled",
"debug_mode",
"ssl_required",
"max_connections",
"backup_enabled"
];
writeOutput("<h2>Configuration Analysis</h2>");
writeOutput("<table border='1' cellpadding='8'>");
writeOutput("<tr><th>Setting</th><th>Source File</th><th>Value</th><th>Status</th></tr>");
configSummary = {};
for (setting in requiredSettings) {
//writeOutput("<tr style='background-color: #f5f5f5;'>");
writeOutput("<td colspan='4'><strong>" & UCase(setting) & "</strong></td>");
writeOutput("</tr>");
settingFound = false;
for (config in configSources) {
result = parseConfig(config.content, setting);
if (result.found) {
settingFound = true;
statusColor = "green";
statusText = "✅ Found";
// Store in summary
configSummary[setting] = result.value;
} else {
statusColor = "lightgray";
statusText = "❌ Not found";
}
writeOutput("<tr>");
writeOutput("<td style='padding-left: 20px;'>" & setting & "</td>");
writeOutput("<td>" & config.source & "</td>");
writeOutput("<td>" & (result.found ? result.value : "-") & "</td>");
writeOutput("<td style='color: " & (result.found ? "green" : "red") & ";'>" & statusText & "</td>");
writeOutput("</tr>");
}
if (!settingFound) {
writeOutput("<tr>");
writeOutput("<td colspan='4' style='color: red; font-style: italic; text-align: center;'>⚠ Setting not found in any configuration file</td>");
writeOutput("</tr>");
}
}
writeOutput("</table>");
// Final configuration summary
writeOutput("<h3>Final Configuration Summary</h3>");
//writeOutput("<div style='background-color: #f0f8ff; padding: 15px; border: 1px solid #ccc;'>");
if (structCount(configSummary) > 0) {
for (setting in configSummary) {
writeOutput("<p><strong>" & UCase(setting) & ":</strong> " & configSummary[setting] & "</p>");
}
} else {
writeOutput("<p style='color: red;'>⚠ No valid configuration settings found</p>");
}
writeOutput("</div>");
</cfscript>
