var nextMatch = 1;
var objMatch = "";
var outstring = "";
var thisURL = "";
var thisLink = "";
var target = IIf(arrayLen(arguments) gte 2, "arguments[2]", DE(""));
var paragraph = IIf(arrayLen(arguments) gte 3, "arguments[3]", DE("false"));
do {
objMatch = REFindNoCase("(((https?:|ftp:|gopher:)\/\/)|(www\.|ftp\.))[-[:alnum:]\?%,\.\/#!;@:=\+~_]+[A-Za-z0-9\/]", string, nextMatch, true);
if (objMatch.pos[1] GT nextMatch OR objMatch.pos[1] EQ nextMatch) {
outString = outString & Mid(String, nextMatch, objMatch.pos[1] - nextMatch);
} else {
outString = outString & Mid(String, nextMatch, Len(string));
}
nextMatch = objMatch.pos[1] + objMatch.len[1];
if (ArrayLen(objMatch.pos) GT 1) {
// If the preceding character is an @, assume this is an e-mail address
// (for addresses like admin@ftp.cdrom.com)
if (Compare(Mid(String, Max(objMatch.pos[1] - 1, 1), 1), "@") NEQ 0) {
thisURL = Mid(String, objMatch.pos[1], objMatch.len[1]);
thisLink = "" & thisURL & "";
outString = outString & thisLink;
// String = Replace(String, thisURL, thisLink);
// nextMatch = nextMatch + Len(thisURL);
} else {
outString = outString & Mid(String, objMatch.pos[1], objMatch.len[1]);
}
}
} while (nextMatch GT 0);
// Now turn e-mail addresses into mailto: links.
outString = REReplace(outString, "([[:alnum:]_\.\-]+@([[:alnum:]_\.\-]+\.)+[[:alpha:]]{2,4})", "\1", "ALL");
if (paragraph) {
outString = ParagraphFormat(outString);
}
return outString;
/* Convert special characters so they do not get interpreted literally; italicize and boldface */
data = REReplaceNoCase(data, '&([[:alpha:]]{2,});', '«strong»«em»&\1;«/em»«/strong»', 'ALL');
/* Convert many standalone (not within quotes) numbers to blue, ie. myValue = 0 */
data = REReplaceNoCase(data, "(gt|lt|eq|is|,|\(|\))([[:space:]]?[0-9]{1,})", "\1«span style='color: ##0000ff'»\2«/span»", "ALL");
/* Convert normal tags to navy blue */
data = REReplaceNoCase(data, "<(/?)((!d|b|c(e|i|od|om)|d|e|f(r|o)|h|i|k|l|m|n|o|p|q|r|s|t(e|i|t)|u|v|w|x)[^>]*)>", "«span style='color: ##000080'»<\1\2>«/span»", "ALL");
/* Convert all table-related tags to teal */
data = REReplaceNoCase(data, "<(/?)(t(a|r|d|b|f|h)([^>]*)|c(ap|ol)([^>]*))>", "«span style='color: ##008080'»<\1\2>«/span»", "ALL");
/* Convert all form-related tags to orange */
data = REReplaceNoCase(data, "<(/?)((bu|f(i|or)|i(n|s)|l(a|e)|se|op|te)([^>]*))>", "«span style='color: ##ff8000'»<\1\2>«/span»", "ALL");
/* Convert all tags starting with 'a' to green, since the others aren't used much and we get a speed gain */
data = REReplaceNoCase(data, "<(/?)(a[^>]*)>", "«span style='color: ##008000'»<\1\2>«/span»", "ALL");
/* Convert all image and style tags to purple */
data = REReplaceNoCase(data, "<(/?)((im[^>]*)|(sty[^>]*))>", "«span style='color: ##800080'»<\1\2>«/span»", "ALL");
/* Convert all ColdFusion, SCRIPT and WDDX tags to maroon */
data = REReplaceNoCase(data, "<(/?)((cf[^>]*)|(sc[^>]*)|(wddx[^>]*))>", "«span style='color: ##800000'»<\1\2>«/span»", "ALL");
/* Convert all inline "//" comments to gray (revised) */
data = REReplaceNoCase(data, "([^:/]\/{2,2})([^[:cntrl:]]+)($|[[:cntrl:]])", "«span style='color: ##808080'»«em»\1\2«/em»«/span»", "ALL");
/* Convert all multi-line script comments to gray */
data = REReplaceNoCase(data, "(\/\*[^\*]*\*\/)", "«span style='color: ##808080'»«em»\1«/em»«/span»", "ALL");
/* Convert all HTML and ColdFusion comments to gray */
/* The next 10 lines of code can be replaced with the commented-out line following them, if you do care whether HTML and CFML
comments contain colored markup. */
while(NOT EOF) {
Match = REFindNoCase("", data, BOF, True);
if (Match.pos[1]) {
Orig = Mid(data, Match.pos[1], Match.len[1]);
Chunk = REReplaceNoCase(Orig, "«(/?[^»]*)»", "", "ALL");
BOF = ((Match.pos[1] + Len(Chunk)) + 38); // 38 is the length of the SPAN tags in the next line
data = Replace(data, Orig, "«span style='color: ##808080'»«em»#Chunk#«/em»«/span»");
} else EOF = 1;
}
/* Convert all quoted values to blue */
data = REReplaceNoCase(data, """([^""]*)""", "«span style=""color: ##0000ff""»""\1""«/span»", "all");
/* Convert left containers to their ASCII equivalent */
data = REReplaceNoCase(data, "<", "<", "ALL");
/* Convert right containers to their ASCII equivalent */
data = REReplaceNoCase(data, ">", ">", "ALL");
/* Revert all pseudo-containers back to their real values to be interpreted literally (revised) */
data = REReplaceNoCase(data, "«([^»]*)»", "<\1>", "ALL");
/* ***New Feature*** Convert all FILE and UNC paths to active links (i.e, file:///, \\server\, c:\myfile.cfm) */
data = REReplaceNoCase(data, "(((file:///)|([a-z]:\\)|(\\\\[[:alpha:]]))+(\.?[[:alnum:]\/=^@*|:~`+$%?_##& -])+)", "\1", "ALL");
/* Convert all URLs to active links (revised) */
data = REReplaceNoCase(data, "([[:alnum:]]*://[[:alnum:]\@-]*(\.[[:alnum:]][[:alnum:]-]*[[:alnum:]]\.)?[[:alnum:]]{2,}(\.?[[:alnum:]\/=^@*|:~`+$%?_##&-])+)", "\1", "ALL");
/* Convert all email addresses to active mailto's (revised) */
data = REReplaceNoCase(data, "(([[:alnum:]][[:alnum:]_.-]*)?[[:alnum:]]@[[:alnum:]][[:alnum:].-]*\.[[:alpha:]]{2,})", "\1", "ALL");
","all") />
" & data & "" />
insert into #arguments.tableprefix#search_log(searchterms, datesearched)
values(,
)
//first make Windows style into Unix style
str = replace(str,chr(13)&chr(10),chr(10),"ALL");
//now make Macintosh style into Unix style
str = replace(str,chr(13),chr(10),"ALL");
//now fix tabs
str = replace(str,chr(9)," ","ALL");
//now return the text formatted in HTML
return replace(str,chr(10),"
","ALL");