BBcodes hjælp..
Jeg fandet dette script på nette. og vil tilføje [ img] [ /img] funktionen... men den skriver en fejl.Error Type:
Sun ONE ASP VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'ReplaceRegExp'
/test.asp, line 29
<%
'----------------------------------------
' Common Regular Expression Function
'----------------------------------------
Function ReplaceRegExp(strString, strPattern, strReplace)
Dim RE: Set RE = New RegExp
With RE
.Pattern = strPattern
.Global = True
ReplaceRegExp = .Replace(strString, strReplace)
End With
End Function
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'----------------------------------------
' Turn BBcode into HTML
'----------------------------------------
Function BBCodeToHTML(strString)
strString = ReplaceRegExp(strString, "(http|ftp|https)(:\/\/[\w\-_]+)((\.[\w\-_]+)+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?", "<a href=""$1$2$3$5"" target=""_blank"">$1$2$3$5</a>")
strString = ReplaceRegExp(strString, "\[color=([^\]]*)\]([^\[]*)\[/color\]", "<span style=""color: $1;"">$2</span>")
strString = ReplaceRegExp(strString, "\[size=([^\]]*)\]([^\[]*)\[/size\]", "<font size=""$1"">$2</font>")
strString = ReplaceRegExp(strString, "\[font=([^\]]*)\]([^\[]*)\[/font\]", "<span style=""font-family: $1, Sans-Serif, Serif;"">$2</span>")
strString = ReplaceRegExp(strString, "\[quote=([^\]]*)\]([^\[]*)\[/quote\]", "<div class=""quote""><span style=""font-weight: bold; font-size: 8pt;"">$1 said:</span><pre class=""quote1"">$2</pre></div>")
---> 29 strString = ReplaceRegExp(strString, "\[img\](.*?)\[/img\]")
strString = Replace(strString,"<img src='$1'/>")
strString = Replace(strString, "", "<span style=""font-weight: bold;"">")
strString = Replace(strString, "[B]", "<span style=""font-weight: bold;"">")
strString = Replace(strString, "", "<span style=""text-decoration: underline;"">")
strString = Replace(strString, "[U]", "<span style=""text-decoration: underline;"">")
strString = Replace(strString, "", "<span style="" font-style: italic;"">")
strString = Replace(strString, "[I]", "<span style="" font-style: italic;"">")
strString = Replace(strString, "", "</span>")
strString = Replace(strString, "[/B]", "</span>")
strString = Replace(strString, "", "</span>")
strString = Replace(strString, "[/U]", "</span>")
strString = Replace(strString, "", "</span>")
strString = Replace(strString, "[/I]", "</span>")
strString = Replace(strString, "[/i]", "<ul><li>")
strString = Replace(strString, "[LI]", "<ul><li>")
strString = Replace(strString, "[Li]", "<ul><li>")
strString = Replace(strString, "[lI]", "<ul><li>")
strString = Replace(strString, "[/li]", "</li></ul>")
strString = Replace(strString, "[/LI]", "</li></ul>")
strString = Replace(strString, "[/Li]", "</li></ul>")
strString = Replace(strString, "[/lI]", "</li></ul>")
BBCodeToHTML = strString
End Function
strTest = "blah blah http://www.thisisaurl.com blah blah Orange Text blah blah Size 7 Text blah blah Arial Font blah blah [quote=BBD]This is what BBD said.[/quote] blah blah Bold Text blah blah Underlined Text blah blah Italicized Text blah blah [li]Listed Text[/li] blah blah http://www.helsingorkommune.dk/upload/gl-skib.jpg"
strOutput = BBCodeToHTML(strTest)
Response.Write(strOutput)
%>