Avatar billede Meggel Novice
05. marts 2009 - 20:26 Der er 1 kommentar og
1 løsning

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)

%>
Avatar billede Meggel Novice
05. marts 2009 - 20:33 #1
www.arashorse.com/bbcodes.txt  der kan koden uden alle de understreg og sager.
Avatar billede Meggel Novice
01. marts 2013 - 14:30 #2
droppet det projekt
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester