gør keywords til link - soter array efter længde på ord
'-------------------------------------------------------------------------------------------------------------'CONSTANTS
WORD_CHARS_U = "ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ"
WORD_CHARS_L = "abcdefghijklmnopqrstuvwxyzæøå"
NUMERIC_CHARS = "1234567890"
WORD_CHARS = WORD_CHARS_U&WORD_CHARS_L&NUMERIC_CHARS
WORD_CHARS_LEN = len(WORD_CHARS)
'-------------------------------------------------------------------------------------------------------------
'VARIABLES
fSeparator = ","
fWordArr = split(ArrOfWords,fSeparator) 'SKAL VÆRE LCASE...
'-------------------------------------------------------------------------------------------------------------
'FUNCTIONS
function isWordChar(aCh)%><%isWordChar=true
for c=1 to WORD_CHARS_LEN
if aCh=mid(WORD_CHARS,c,1) then exit function
next%><%isWordChar=false
end function
function inWrdArr(aWrd)%><%inWrdArr=true
for c=lBound(fWordArr) to uBound(fWordArr)
if aWrd=fWordArr(c) then exit function
next%><%inWrdArr=false
end function
function inWrdArrLike(aWrd)%><%inWrdArrLike=true
for c=lBound(fWordArr) to uBound(fWordArr)
aItm=fWordArr(c)
if (aWrd=left(aItm,len(aWrd))) and (aWrd<>aItm) then exit function
next%><%inWrdArrLike=false
end function
function highlightText(aText)
aLen=len(aText)%><%result=true%><%aWrd=""
if aLen<1 then exit function
for i=1 to aLen%><%ch=mid(aText,i,1)
if isWordChar(ch) then%><%aWrd=aWrd&ch%><%else
if aWrd<>"" then%><%lcWrd=lCase(aWrd)
if inWrdArr(lcWrd) then
%><a href="#" title="<%=aWrd%>">[<a title="<%=aWrd%>" href="http://www.killmyday.com/default.asp?Keyword=<%=aWrd%>&Search=go"><%=aWrd%></a>]</a><%aWrd=""
else
if inWrdArrLike(lcWrd) then%><%aWrd=aWrd&ch%><%else%><%=aWrd%><%aWrd=""%><%end if
end if
end if%><%=ch%><%
end if
next%><%=aWrd%><%
end function
'-------------------------------------------------------------------------------------------------------------
'TESTING
aText = sContent
PrintText = highlightText(aText)
Overstående kode spiller ikke helt da den ikke kan finde ud af hvis 2 ord udgør et keyword, så jeg tænkte om man ikke bare kunne smide alle keywords ind i et array og så soter dem efter længde og så lave en simpel if instr(sContent,keyword(i)) then replace(keyword(i),"detderskalreplace") end if.
Hvordan soter man et array efter længden på de ord der er i den ?
