Försöker bli klok på Reg. Exp. men det går inget vidare.
Det hela är till en sökfunktion som ska söka igenom en databas. Alla poster i databasen är i VARCHAR (mysql).
Problemet kommer då man söker efter "0200". Det finns en post som heter just 0200, men den hittas inte. Däremot hittas 02 och 2000.
Samma sak gäller när man söker efter . (punkt).
Function PunchWord(astring)
astring = Replace(astring,",","%")
Set objRegExp = New RegExp
objRegExp.Global = True
objRegExp.IgnoreCase = true objRegExp.Pattern = sokord
Set matches = objRegExp.Execute(astring)
For Each match In matches
astring = Replace(astring,match,"<b>" & match & "</b>")
Next
Set matches = Nothing
Set objRegExp = Nothing
astring = Replace(astring,"%",",")
PunchWord = astring
End Function
Function PunchWord(astring)
Set objRegExp = New RegExp
objRegExp.Global = True
objRegExp.IgnoreCase = true objRegExp.Pattern = "" & Replace(sokord,".","\.")
Set matches = objRegExp.Execute(astring)
For Each match In matches
astring = Replace(astring,match,"<b>" & match & "</b>")
Next
Set matches = Nothing
Set objRegExp = Nothing
PunchWord = astring
End Function
<%
Function PunchWord(astring,sokord)
Set objRegExp = New RegExp
objRegExp.Global = True
objRegExp.IgnoreCase = true
objRegExp.Pattern = "" & Replace(sokord,".","\.")
Set matchesa = objRegExp.Execute(astring)
For Each matcha In matchesa
astring = Replace(astring,matcha,"<b>" & matcha & "</b>")
Next
Set matches = Nothing
Set objRegExp = Nothing
PunchWord = astring
End Function
%>
<%=PunchWord("min text her sa det sa","text")%>
<%
Function PunchWord(astring,sokord)
sokord = Replace(sokord,".","\.")
apa = split(sokord,",")
nya = ""
for i = 0 to ubound(apa)
nya = nya & "(" & apa(i) & ")"
if i <> ubound(apa) then
nya = nya & "|"
end if
next
Set objRegExp = New RegExp
objRegExp.Global = True
objRegExp.IgnoreCase = true
objRegExp.Pattern = nya
Set matchesa = objRegExp.Execute(astring)
For Each matcha In matchesa
astring = Replace(astring,matcha,"<b>" & matcha & "</b>")
Next
Set matches = Nothing
Set objRegExp = Nothing
PunchWord = astring
End Function
%>
<%=PunchWord("her har du en hel hog med ord ser du","har,hel,ord")%>
alltså dela upp med ,
259 ms totalt · 4 externa anrop · v20260731065814-full.51f67c91