- 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. The search is case sensitive.
Returns
A number; the position of substring in string; or 0, if substring is not in string.
Category
Function syntax
Find(substring, string [, start ]) |
See also
FindNoCase, Compare, FindOneOf, REFind, Replace
Parameters
Parameter |
Description |
|---|---|
substring |
The string that you are searching for. |
string |
The string in which to search for the substring. |
start |
The position to start searching in the string (starts at 1). |
Example
<cfoutput>
<cfset stringToSearch = "The quick brown fox jumped over the lazy dog.">
#find("the",stringToSearch)#<br>
#find("the",stringToSearch,35)#<br>
#find("no such substring",stringToSearch)#<br>
</cfoutput>
Real-world use cases of the Find function
Log file analysis and error detection
IT operations teams need to monitor server logs, application logs, and error files to identify critical issues, performance bottlenecks, and security threats across enterprise systems. Manual log analysis is time-consuming and error-prone. Critical errors can go undetected for hours or days, leading to system downtime, data loss, and customer impact. Organizations process terabytes of log data daily. Use Find to locate specific error codes, timestamps, IP addresses, and patterns in log files for automated monitoring and alerting.
<cfscript>
// Sample log entries from different systems
logEntries = [
"2024-10-27 10:15:23 INFO: User login successful - IP: 192.168.1.100 - User: john.doe",
"2024-10-27 10:16:45 ERROR: Database connection failed - Code: DB001 - Timeout: 30s",
"2024-10-27 10:17:12 WARN: High memory usage detected - 85% utilization - Server: web01",
"2024-10-27 10:18:33 ERROR: Authentication failed - IP: 203.0.113.1 - Attempts: 3",
"2024-10-27 10:19:56 INFO: File upload completed - Size: 2.5MB - File: report.pdf",
"2024-10-27 10:20:15 CRITICAL: Disk space low - 95% used - Drive: C:\\",
"2024-10-27 10:21:42 ERROR: Payment processing failed - Code: PAY005 - Amount: $299.99"
];
</cfscript>
<cfoutput>
<h2>📊 Log Analysis Results</h2>
<cfloop array="#logEntries#" index="logEntry">
<cfscript>
// Use Find function to detect log patterns
errorPos = Find("ERROR:", logEntry);
warnPos = Find("WARN:", logEntry);
infoPos = Find("INFO:", logEntry);
criticalPos = Find("CRITICAL:", logEntry);
// Determine log level and color
if (criticalPos GT 0) {
logLevel = "CRITICAL";
levelColor = "##8B0000";
priority = "Urgent";
} else if (errorPos GT 0) {
logLevel = "ERROR";
levelColor = "##dc3545";
priority = "High";
} else if (warnPos GT 0) {
logLevel = "WARNING";
levelColor = "##ffc107";
priority = "Medium";
} else if (infoPos GT 0) {
logLevel = "INFO";
levelColor = "##17a2b8";
priority = "Low";
} else {
logLevel = "UNKNOWN";
levelColor = "##6c757d";
priority = "Low";
}
// Extract additional information using Find
ipPos = Find("IP: ", logEntry);
codePos = Find("Code: ", logEntry);
userPos = Find("User: ", logEntry);
sizePos = Find("Size: ", logEntry);
// Extract timestamp (first 19 characters)
timestamp = Left(logEntry, 19);
// Extract IP address if found
ipAddress = "";
if (ipPos GT 0) {
ipStart = ipPos + 4;
ipEnd = Find(" ", logEntry, ipStart);
if (ipEnd EQ 0) ipEnd = Len(logEntry) + 1;
ipAddress = Mid(logEntry, ipStart, ipEnd - ipStart);
}
// Extract error code if found
errorCode = "";
if (codePos GT 0) {
codeStart = codePos + 6;
codeEnd = Find(" ", logEntry, codeStart);
if (codeEnd EQ 0) codeEnd = Len(logEntry) + 1;
errorCode = Mid(logEntry, codeStart, codeEnd - codeStart);
}
</cfscript>
<div style="background: white; padding: 20px; margin: 15px 0; border-radius: 8px; border-left: 5px solid #levelColor#; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; align-items: start;">
<!-- Log Entry Info -->
<div>
<h3 style="margin-top: 0; color: ##333;">Log Entry Analysis</h3>
<p><strong>Timestamp:</strong> #timestamp#</p>
<p><strong>Level:</strong> <span style="color: #levelColor#; font-weight: bold;">#logLevel#</span></p>
<p><strong>Priority:</strong> #priority#</p>
<p><strong>Entry Length:</strong> #Len(logEntry)# characters</p>
</div>
<!-- Find Function Usage -->
<div>
<h4 style="margin-top: 0;">🔍 Find Results</h4>
<div style="background: ##f8f9fa; padding: 10px; border-radius: 3px; font-family: monospace; font-size: 0.85em;">
<cfif errorPos GT 0>
<p><strong>ERROR:</strong> position #errorPos#</p>
</cfif>
<cfif warnPos GT 0>
<p><strong>WARN:</strong> position #warnPos#</p>
</cfif>
<cfif criticalPos GT 0>
<p><strong>CRITICAL:</strong> position #criticalPos#</p>
</cfif>
<cfif ipPos GT 0>
<p><strong>IP:</strong> position #ipPos#</p>
</cfif>
<cfif codePos GT 0>
<p><strong>Code:</strong> position #codePos#</p>
</cfif>
</div>
</div>
<!-- Extracted Data -->
<div>
<h4 style="margin-top: 0;">📊 Extracted Information</h4>
<cfif Len(ipAddress) GT 0>
<p><strong>IP Address:</strong> #ipAddress#</p>
</cfif>
<cfif Len(errorCode) GT 0>
<p><strong>Error Code:</strong> #errorCode#</p>
</cfif>
<cfif userPos GT 0>
<p><strong>Contains User Info:</strong> Yes</p>
</cfif>
<cfif sizePos GT 0>
<p><strong>Contains Size Info:</strong> Yes</p>
</cfif>
</div>
</div>
<!-- Full Log Entry -->
<div style="background: ##f8f9fa; padding: 12px; border-radius: 5px; margin-top: 15px;">
<h5 style="margin-top: 0;">📝 Full Log Entry:</h5>
<code style="word-break: break-all;">#logEntry#</code>
</div>
<!-- Automated Actions -->
<div style="background: rgba(255,255,255,0.8); padding: 12px; border-radius: 5px; margin-top: 15px;">
<strong>🚨 Automated Actions:</strong>
<cfif logLevel EQ "CRITICAL">
<br>• Send immediate alert to on-call engineer
<br>• Create high-priority incident ticket
<br>• Escalate to management within 15 minutes
<br>• Initiate disaster recovery procedures if needed
<cfelseif logLevel EQ "ERROR">
<br>• Create incident ticket and assign to support team
<br>• Send notification to system administrators
<br>• Log error pattern for trend analysis
<br>• Check for related system impacts
<cfelseif logLevel EQ "WARNING">
<br>• Add to monitoring dashboard for trend tracking
<br>• Schedule preventive maintenance if pattern detected
<br>• Send daily summary report to operations team
<cfelse>
<br>• Archive for compliance and audit purposes
<br>• Include in daily operational reports
<br>• Track for capacity planning and optimization
</cfif>
</div>
</div>
</cfloop>
<h2>📈 Log Analysis Summary</h2>
<div style="background: ##f8f9fa; padding: 20px; border-radius: 8px; margin: 15px 0;">
<cfscript>
// Calculate summary statistics
totalEntries = ArrayLen(logEntries);
errorCount = 0;
warningCount = 0;
infoCount = 0;
criticalCount = 0;
ipAddressCount = 0;
errorCodeCount = 0;
for (entry in logEntries) {
if (Find("ERROR:", entry) GT 0) errorCount++;
if (Find("WARN:", entry) GT 0) warningCount++;
if (Find("INFO:", entry) GT 0) infoCount++;
if (Find("CRITICAL:", entry) GT 0) criticalCount++;
if (Find("IP: ", entry) GT 0) ipAddressCount++;
if (Find("Code: ", entry) GT 0) errorCodeCount++;
}
</cfscript>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##8B0000;">#criticalCount#</h3>
<p style="margin: 5px 0 0 0;">Critical Events</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##dc3545;">#errorCount#</h3>
<p style="margin: 5px 0 0 0;">Error Events</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##ffc107;">#warningCount#</h3>
<p style="margin: 5px 0 0 0;">Warning Events</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#infoCount#</h3>
<p style="margin: 5px 0 0 0;">Info Events</p>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##6f42c1;">#ipAddressCount#</h3>
<p style="margin: 5px 0 0 0;">Entries with IP Addresses</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##fd7e14;">#errorCodeCount#</h3>
<p style="margin: 5px 0 0 0;">Entries with Error Codes</p>
</div>
</div>
</div>
</cfoutput>
Content management and SEO optimization
Digital marketing teams manage thousands of web pages, blog articles, and product descriptions requiring SEO optimization, content quality control, and brand consistency. Manual content review is impractical at scale. Inconsistent keywords, missing SEO elements, and brand guideline violations reduce search rankings and traffic. Content teams need automated quality assurance. Use Find to locate keywords, URLs, brand terms, and SEO elements in content for automated analysis and optimization recommendations.
<cfscript>
// Sample content from various marketing materials
contentSamples = [
"Our premium ColdFusion hosting service offers 99.9% uptime guarantee with 24/7 support. Contact us at support@example.com for personalized assistance.",
"Learn advanced ColdFusion techniques with our comprehensive tutorial series. Visit https://learn.coldfusion.com for free resources and expert guidance.",
"Enterprise ColdFusion solutions include development, database optimization, and cloud migration services. Special offer: 50% off consultation.",
"Join thousands of developers who trust our ColdFusion platform for mission-critical applications. Call 1-800-COLDFUSION today!",
"ColdFusion 2023 features enhanced security, improved performance, and modern API capabilities. Download free trial at https://www.adobe.com/coldfusion"
];
</cfscript>
<cfoutput>
<h2>📊 Content Analysis Results</h2>
<cfloop array="#contentSamples#" index="content">
<cfscript>
// SEO and brand keyword analysis using Find
cfPos = Find("ColdFusion", content);
premiumPos = Find("premium", content);
enterprisePos = Find("Enterprise", content);
supportPos = Find("support", content);
freePos = Find("free", content);
// Contact and engagement elements
emailPos = Find("@", content);
phonePos = Find("1-800", content);
contactPos = Find("Contact", content);
callPos = Find("Call", content);
// URLs and links
httpsPos = Find("https://", content);
httpPos = Find("http://", content);
wwwPos = Find("www.", content);
// Promotional and conversion elements
offerPos = Find("offer", content);
discountPos = Find("%", content);
guaranteePos = Find("guarantee", content);
trialPos = Find("trial", content);
// Calculate SEO score based on found elements
seoScore = 0;
// Brand and product mentions
if (cfPos GT 0) seoScore += 15;
if (premiumPos GT 0) seoScore += 8;
if (enterprisePos GT 0) seoScore += 10;
// Contact and engagement
if (emailPos GT 0) seoScore += 12;
if (phonePos GT 0) seoScore += 10;
if (contactPos GT 0 OR callPos GT 0) seoScore += 8;
// Web presence
if (httpsPos GT 0 OR httpPos GT 0) seoScore += 15;
if (wwwPos GT 0) seoScore += 5;
// Conversion elements
if (offerPos GT 0) seoScore += 10;
if (discountPos GT 0) seoScore += 12;
if (guaranteePos GT 0) seoScore += 8;
if (trialPos GT 0) seoScore += 10;
if (freePos GT 0) seoScore += 8;
// Determine content quality rating
if (seoScore GTE 50) {
quality = "Excellent";
qualityColor = "##28a745";
} else if (seoScore GTE 35) {
quality = "Good";
qualityColor = "##17a2b8";
} else if (seoScore GTE 20) {
quality = "Average";
qualityColor = "##ffc107";
} else {
quality = "Needs Improvement";
qualityColor = "##dc3545";
}
// Extract URLs if found
extractedURL = "";
if (httpsPos GT 0) {
urlStart = httpsPos;
urlEnd = Find(" ", content, urlStart);
if (urlEnd EQ 0) urlEnd = Len(content) + 1;
extractedURL = Mid(content, urlStart, urlEnd - urlStart);
} else if (httpPos GT 0) {
urlStart = httpPos;
urlEnd = Find(" ", content, urlStart);
if (urlEnd EQ 0) urlEnd = Len(content) + 1;
extractedURL = Mid(content, urlStart, urlEnd - urlStart);
}
// Extract email if found
extractedEmail = "";
if (emailPos GT 0) {
emailStart = emailPos;
// Find start of email (go backwards)
while (emailStart GT 1 AND Mid(content, emailStart - 1, 1) NEQ " ") {
emailStart--;
}
// Find end of email (go forwards)
emailEnd = emailPos;
while (emailEnd LT Len(content) AND Mid(content, emailEnd + 1, 1) NEQ " ") {
emailEnd++;
}
extractedEmail = Mid(content, emailStart, emailEnd - emailStart + 1);
}
</cfscript>
<div style="background: white; padding: 20px; margin: 15px 0; border-radius: 8px; border-left: 5px solid #qualityColor#; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; align-items: start;">
<!-- Content Overview -->
<div>
<h3 style="margin-top: 0; color: ##333;">Content Analysis</h3>
<p><strong>Content Preview:</strong> "#Left(content, 60)#..."</p>
<p><strong>Length:</strong> #Len(content)# characters</p>
<p><strong>SEO Score:</strong> #seoScore# points</p>
<p><strong>Quality:</strong> <span style="color: #qualityColor#; font-weight: bold;">#quality#</span></p>
</div>
<!-- Find Function Results -->
<div>
<h4 style="margin-top: 0;">🔍 Keyword Detection</h4>
<div style="background: ##f8f9fa; padding: 10px; border-radius: 3px; font-family: monospace; font-size: 0.85em;">
<cfif cfPos GT 0>
<p><strong>ColdFusion:</strong> position #cfPos#</p>
</cfif>
<cfif premiumPos GT 0>
<p><strong>Premium:</strong> position #premiumPos#</p>
</cfif>
<cfif enterprisePos GT 0>
<p><strong>Enterprise:</strong> position #enterprisePos#</p>
</cfif>
<cfif emailPos GT 0>
<p><strong>Email (@):</strong> position #emailPos#</p>
</cfif>
<cfif httpsPos GT 0>
<p><strong>HTTPS URL:</strong> position #httpsPos#</p>
</cfif>
<cfif offerPos GT 0>
<p><strong>Offer:</strong> position #offerPos#</p>
</cfif>
</div>
</div>
<!-- Extracted Elements -->
<div>
<h4 style="margin-top: 0;">📊 Extracted Data</h4>
<cfif Len(extractedEmail) GT 0>
<p><strong>Email:</strong> #Trim(extractedEmail)#</p>
</cfif>
<cfif Len(extractedURL) GT 0>
<p><strong>URL:</strong> #extractedURL#</p>
</cfif>
<cfif phonePos GT 0>
<p><strong>Phone:</strong> Found toll-free number</p>
</cfif>
<cfif guaranteePos GT 0>
<p><strong>Guarantee:</strong> Customer assurance present</p>
</cfif>
<cfif freePos GT 0>
<p><strong>Free Offer:</strong> Conversion incentive found</p>
</cfif>
</div>
</div>
<!-- SEO Analysis Details -->
<div style="background: ##f8f9fa; padding: 15px; border-radius: 5px; margin-top: 15px;">
<h5 style="margin-top: 0;">📈 SEO Element Analysis:</h5>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px;">
<!-- Brand Elements -->
<div style="background: white; padding: 10px; border-radius: 3px;">
<h6 style="margin-top: 0; color: ##17a2b8;">Brand Elements</h6>
<p style="margin: 2px 0;">ColdFusion Mention: #cfPos GT 0 ? 'Yes (+15)' : 'No (0)'#</p>
<p style="margin: 2px 0;">Premium Positioning: #premiumPos GT 0 ? 'Yes (+8)' : 'No (0)'#</p>
<p style="margin: 2px 0;">Enterprise Focus: #enterprisePos GT 0 ? 'Yes (+10)' : 'No (0)'#</p>
</div>
<!-- Contact Elements -->
<div style="background: white; padding: 10px; border-radius: 3px;">
<h6 style="margin-top: 0; color: ##28a745;">Contact Elements</h6>
<p style="margin: 2px 0;">Email Contact: #emailPos GT 0 ? 'Yes (+12)' : 'No (0)'#</p>
<p style="margin: 2px 0;">Phone Number: #phonePos GT 0 ? 'Yes (+10)' : 'No (0)'#</p>
<p style="margin: 2px 0;">Contact CTA: #(contactPos GT 0 OR callPos GT 0) ? 'Yes (+8)' : 'No (0)'#</p>
</div>
<!-- Conversion Elements -->
<div style="background: white; padding: 10px; border-radius: 3px;">
<h6 style="margin-top: 0; color: ##fd7e14;">Conversion Elements</h6>
<p style="margin: 2px 0;">Special Offer: #offerPos GT 0 ? 'Yes (+10)' : 'No (0)'#</p>
<p style="margin: 2px 0;">Free Elements: #freePos GT 0 ? 'Yes (+8)' : 'No (0)'#</p>
<p style="margin: 2px 0;">Guarantee: #guaranteePos GT 0 ? 'Yes (+8)' : 'No (0)'#</p>
</div>
</div>
</div>
<!-- Content Recommendations -->
<div style="background: rgba(255,255,255,0.8); padding: 12px; border-radius: 5px; margin-top: 15px;">
<strong>💡 Content Optimization Recommendations:</strong>
<cfif quality EQ "Excellent">
<br>• Content meets high SEO standards - maintain quality
<br>• Consider A/B testing different CTAs for optimization
<br>• Monitor conversion rates and adjust messaging
<br>• Use as template for similar content pieces
<cfelseif quality EQ "Good">
<br>• Add more conversion-focused elements (offers, guarantees)
<br>• Include additional contact methods for better accessibility
<br>• Consider adding customer testimonials or social proof
<br>• Optimize for specific long-tail keywords
<cfelseif quality EQ "Average">
<br>• Strengthen brand messaging with more keyword mentions
<br>• Add clear contact information and calls-to-action
<br>• Include value propositions and unique selling points
<br>• Consider restructuring for better readability
<cfelse>
<br>• Significant content improvements needed for SEO performance
<br>• Add brand keywords, contact information, and CTAs
<br>• Include compelling offers and conversion incentives
<br>• Consider complete content rewrite with SEO focus
</cfif>
</div>
</div>
</cfloop>
<h2>📈 Content Performance Dashboard</h2>
<div style="background: ##f8f9fa; padding: 20px; border-radius: 8px; margin: 15px 0;">
<cfscript>
// Calculate overall content performance metrics
totalContent = ArrayLen(contentSamples);
excellentCount = 0;
goodCount = 0;
averageCount = 0;
needsImprovementCount = 0;
totalSEOScore = 0;
hasEmail = 0;
hasURL = 0;
hasBrand = 0;
hasOffer = 0;
for (content in contentSamples) {
// Calculate individual scores and categorize
local.score = 0;
if (Find("ColdFusion", content) GT 0) {
local.score += 15;
hasBrand++;
}
if (Find("premium", content) GT 0) local.score += 8;
if (Find("Enterprise", content) GT 0) local.score += 10;
if (Find("@", content) GT 0) {
local.score += 12;
hasEmail++;
}
if (Find("1-800", content) GT 0) local.score += 10;
if (Find("Contact", content) GT 0 OR Find("Call", content) GT 0) local.score += 8;
if (Find("https://", content) GT 0 OR Find("http://", content) GT 0) {
local.score += 15;
hasURL++;
}
if (Find("www.", content) GT 0) local.score += 5;
if (Find("offer", content) GT 0) {
local.score += 10;
hasOffer++;
}
if (Find("%", content) GT 0) local.score += 12;
if (Find("guarantee", content) GT 0) local.score += 8;
if (Find("trial", content) GT 0) local.score += 10;
if (Find("free", content) GT 0) local.score += 8;
totalSEOScore += local.score;
// Categorize content quality
if (local.score GTE 50) excellentCount++;
else if (local.score GTE 35) goodCount++;
else if (local.score GTE 20) averageCount++;
else needsImprovementCount++;
}
averageSEOScore = totalSEOScore / totalContent;
</cfscript>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#excellentCount#</h3>
<p style="margin: 5px 0 0 0;">Excellent Content</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#goodCount#</h3>
<p style="margin: 5px 0 0 0;">Good Content</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##ffc107;">#averageCount#</h3>
<p style="margin: 5px 0 0 0;">Average Content</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##dc3545;">#needsImprovementCount#</h3>
<p style="margin: 5px 0 0 0;">Needs Improvement</p>
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; margin-top: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##6f42c1;">#NumberFormat(averageSEOScore, "0.0")#</h3>
<p style="margin: 5px 0 0 0;">Average SEO Score</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##fd7e14;">#hasBrand#/#totalContent#</h3>
<p style="margin: 5px 0 0 0;">Brand Mentions</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#hasEmail#/#totalContent#</h3>
<p style="margin: 5px 0 0 0;">Contact Information</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#hasURL#/#totalContent#</h3>
<p style="margin: 5px 0 0 0;">Web Links</p>
</div>
</div>
</div>
</cfoutput>
Data validation and format verification
Financial services, healthcare, and e-commerce organizations process millions of customer records requiring strict data format validation and compliance verification. Invalid data formats lead to processing errors, compliance violations, and customer service issues. Manual validation is impossible at scale. Data quality directly impacts business operations and regulatory compliance. Use Find to validate email formats, phone numbers, account IDs, and other critical data patterns for automated quality assurance.
<cfscript>
// Sample customer data requiring validation
customerData = [
{"type": "Email", "value": "john.doe@company.com", "required": true},
{"type": "Email", "value": "jane.smith@invalid-domain", "required": true},
{"type": "Phone", "value": "555-123-4567", "required": true},
{"type": "Phone", "value": "1-800-SUPPORT", "required": false},
{"type": "Account ID", "value": "ACC-2024-001234", "required": true},
{"type": "Reference", "value": "REF##INV-2024-5678", "required": true},
{"type": "SSN", "value": "123-45-6789", "required": true},
{"type": "Credit Card", "value": "4532-1234-5678-9012", "required": false}
];
</cfscript>
<cfoutput>
<h2>📊 Data Validation Results</h2>
<cfloop array="#customerData#" index="dataItem">
<cfscript>
// Validate different data types using Find function
dataValue = dataItem.value;
dataType = dataItem.type;
isValid = false;
validationMessages = [];
errorMessages = [];
// Email validation
if (dataType EQ "Email") {
atPos = Find("@", dataValue);
dotPos = Find(".", dataValue);
if (atPos GT 1 AND dotPos GT atPos AND dotPos LT Len(dataValue)) {
isValid = true;
ArrayAppend(validationMessages, "Valid email structure detected");
// Check for common invalid patterns
if (Find("invalid", dataValue) GT 0) {
isValid = false;
ArrayAppend(errorMessages, "Domain contains 'invalid' keyword");
}
} else {
ArrayAppend(errorMessages, "Missing required @ symbol or domain extension");
}
}
// Phone number validation
else if (dataType EQ "Phone") {
dashPos = Find("-", dataValue);
digitCount = 0;
// Count digits
for (i = 1; i LTE Len(dataValue); i++) {
if (IsNumeric(Mid(dataValue, i, 1))) {
digitCount++;
}
}
if (dashPos GT 0 AND digitCount GTE 10) {
if (Find("555-", dataValue) GT 0 AND digitCount EQ 10) {
isValid = true;
ArrayAppend(validationMessages, "Valid US phone number format");
} else if (Find("1-800", dataValue) GT 0) {
isValid = true;
ArrayAppend(validationMessages, "Valid toll-free number");
} else {
ArrayAppend(errorMessages, "Unrecognized phone format");
}
} else {
ArrayAppend(errorMessages, "Missing hyphens or insufficient digits");
}
}
// Account ID validation
else if (dataType EQ "Account ID") {
accPos = Find("ACC-", dataValue);
if (accPos EQ 1 AND Len(dataValue) GTE 10) {
isValid = true;
ArrayAppend(validationMessages, "Valid account ID format");
} else {
ArrayAppend(errorMessages, "Must start with ACC- and be at least 10 characters");
}
}
// Reference ID validation
else if (dataType EQ "Reference") {
refPos = Find("REF", dataValue);
hashPos = Find("##", dataValue);
if (refPos EQ 1 AND hashPos EQ 4) {
isValid = true;
ArrayAppend(validationMessages, "Valid reference ID format");
} else {
ArrayAppend(errorMessages, "Must start with REF## pattern");
}
}
// SSN validation
else if (dataType EQ "SSN") {
firstDash = Find("-", dataValue);
secondDash = Find("-", dataValue, firstDash + 1);
if (firstDash EQ 4 AND secondDash EQ 7 AND Len(dataValue) EQ 11) {
isValid = true;
ArrayAppend(validationMessages, "Valid SSN format (XXX-XX-XXXX)");
} else {
ArrayAppend(errorMessages, "Must follow XXX-XX-XXXX format");
}
}
// Credit Card validation
else if (dataType EQ "Credit Card") {
dashCount = 0;
dashPos = 1;
while (dashPos GT 0) {
dashPos = Find("-", dataValue, dashPos + 1);
if (dashPos GT 0) dashCount++;
}
if (dashCount EQ 3 AND Len(dataValue) EQ 19) {
isValid = true;
ArrayAppend(validationMessages, "Valid credit card format (XXXX-XXXX-XXXX-XXXX)");
} else {
ArrayAppend(errorMessages, "Must follow XXXX-XXXX-XXXX-XXXX format");
}
}
// Determine validation status color
statusColor = isValid ? "##28a745" : "##dc3545";
typeColor = "##17a2b8";
</cfscript>
<div style="background: white; padding: 20px; margin: 15px 0; border-radius: 8px; border-left: 5px solid #statusColor#; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; align-items: start;">
<!-- Data Item Info -->
<div>
<h3 style="margin-top: 0; color: ##333;">Data Validation</h3>
<p><strong>Type:</strong> <span style="color: #typeColor#; font-weight: bold;">#dataType#</span></p>
<p><strong>Value:</strong> #dataValue#</p>
<p><strong>Required:</strong> #dataItem.required ? 'Yes' : 'No'#</p>
<p><strong>Status:</strong> <span style="color: #statusColor#; font-weight: bold;">#isValid ? 'Valid' : 'Invalid'#</span></p>
</div>
<!-- Find Function Analysis -->
<div>
<h4 style="margin-top: 0;">🔍 Pattern Detection</h4>
<div style="background: ##f8f9fa; padding: 10px; border-radius: 3px; font-family: monospace; font-size: 0.85em;">
<cfif dataType EQ "Email">
<p><strong>@ symbol:</strong> position #Find("@", dataValue)#</p>
<p><strong>. symbol:</strong> position #Find(".", dataValue)#</p>
<cfelseif dataType EQ "Phone">
<p><strong>- symbol:</strong> position #Find("-", dataValue)#</p>
<cfif Find("1-800", dataValue) GT 0>
<p><strong>1-800:</strong> position #Find("1-800", dataValue)#</p>
</cfif>
<cfelseif dataType EQ "Account ID">
<p><strong>ACC- prefix:</strong> position #Find("ACC-", dataValue)#</p>
<cfelseif dataType EQ "Reference">
<p><strong>REF prefix:</strong> position #Find("REF", dataValue)#</p>
<p><strong>## symbol:</strong> position #Find("##", dataValue)#</p>
<cfelseif dataType EQ "SSN">
<p><strong>First -:</strong> position #Find("-", dataValue)#</p>
<p><strong>Second -:</strong> position #Find("-", dataValue, 5)#</p>
<cfelseif dataType EQ "Credit Card">
<p><strong>Dash count:</strong> #Len(dataValue) - Len(Replace(dataValue, "-", "", "ALL"))#</p>
</cfif>
</div>
</div>
<!-- Validation Results -->
<div>
<h4 style="margin-top: 0;">✅ Validation Details</h4>
<cfif ArrayLen(validationMessages) GT 0>
<div style="color: ##28a745;">
<cfloop array="#validationMessages#" index="message">
<p style="margin: 2px 0; font-size: 0.9em;">✓ #message#</p>
</cfloop>
</div>
</cfif>
<cfif ArrayLen(errorMessages) GT 0>
<div style="color: ##dc3545;">
<cfloop array="#errorMessages#" index="error">
<p style="margin: 2px 0; font-size: 0.9em;">✗ #error#</p>
</cfloop>
</div>
</cfif>
</div>
</div>
<!-- Compliance and Security Notes -->
<cfif dataType EQ "SSN" OR dataType EQ "Credit Card">
<div style="background: ##fff3cd; padding: 12px; border-radius: 5px; margin-top: 15px;">
<h6 style="margin-top: 0;">🔒 Security & Compliance Notes:</h6>
<cfif dataType EQ "SSN">
<p>• SSN data requires PII protection and GDPR compliance</p>
<p>• Encrypt during storage and transmission</p>
<p>• Log all access for audit purposes</p>
<cfelseif dataType EQ "Credit Card">
<p>• Credit card data requires PCI DSS compliance</p>
<p>• Never store full card numbers in plain text</p>
<p>• Use tokenization for payment processing</p>
</cfif>
</div>
</cfif>
</div>
</cfloop>
<h2>📈 Data Quality Dashboard</h2>
<div style="background: ##f8f9fa; padding: 20px; border-radius: 8px; margin: 15px 0;">
<cfscript>
// Calculate validation statistics
totalRecords = ArrayLen(customerData);
validRecords = 0;
invalidRecords = 0;
requiredRecords = 0;
validRequiredRecords = 0;
emailCount = 0;
phoneCount = 0;
accountCount = 0;
piiCount = 0;
for (dataItem in customerData) {
// Re-validate for statistics
local.isValid = false;
dataValue = dataItem.value;
dataType = dataItem.type;
if (dataType EQ "Email") {
emailCount++;
local.atPos = Find("@", dataValue);
local.dotPos = Find(".", dataValue);
if (local.atPos GT 1 AND local.dotPos GT local.atPos AND Find("invalid", dataValue) EQ 0) {
local.isValid = true;
}
} else if (dataType EQ "Phone") {
phoneCount++;
if (Find("-", dataValue) GT 0 AND (Find("555-", dataValue) GT 0 OR Find("1-800", dataValue) GT 0)) {
local.isValid = true;
}
} else if (dataType EQ "Account ID") {
accountCount++;
if (Find("ACC-", dataValue) EQ 1) {
local.isValid = true;
}
} else if (dataType EQ "Reference") {
if (Find("REF", dataValue) EQ 1 AND Find("##", dataValue) EQ 4) {
local.isValid = true;
}
} else if (dataType EQ "SSN" OR dataType EQ "Credit Card") {
piiCount++;
if (dataType EQ "SSN" AND Find("-", dataValue) EQ 4) {
local.isValid = true;
} else if (dataType EQ "Credit Card" AND Len(dataValue) EQ 19) {
local.isValid = true;
}
}
if (local.isValid) validRecords++;
else invalidRecords++;
if (dataItem.required) {
requiredRecords++;
if (local.isValid) validRequiredRecords++;
}
}
validationRate = (validRecords / totalRecords) * 100;
requiredValidationRate = requiredRecords GT 0 ? (validRequiredRecords / requiredRecords) * 100 : 0;
</cfscript>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#validRecords#</h3>
<p style="margin: 5px 0 0 0;">Valid Records</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##dc3545;">#invalidRecords#</h3>
<p style="margin: 5px 0 0 0;">Invalid Records</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#NumberFormat(validationRate, "0.0")#%</h3>
<p style="margin: 5px 0 0 0;">Overall Validation Rate</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##fd7e14;">#NumberFormat(requiredValidationRate, "0.0")#%</h3>
<p style="margin: 5px 0 0 0;">Required Fields Valid</p>
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; margin-top: 20px;">
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##6f42c1;">#emailCount#</h3>
<p style="margin: 5px 0 0 0;">Email Addresses</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##28a745;">#phoneCount#</h3>
<p style="margin: 5px 0 0 0;">Phone Numbers</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##17a2b8;">#accountCount#</h3>
<p style="margin: 5px 0 0 0;">Account IDs</p>
</div>
<div style="background: white; padding: 15px; border-radius: 5px; text-align: center;">
<h3 style="margin: 0; color: ##dc3545;">#piiCount#</h3>
<p style="margin: 5px 0 0 0;">PII Records</p>
</div>
</div>
</div>
</cfoutput>
