Whatever message this page gives is out now! Go check it out!
Find(substring, string [, start ]) |
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). |
<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><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><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><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>