Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Function BBCodeToHTML(strString)

    Salve a tutti.

    Ho inserito il BBCode all'interno di un form e lo gestisco con questa funzione:

    codice:
    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
    
    Function BBCodeToHTML(strString)
    	strString = ReplaceRegExp(strString, "(http|ftp|https)(:\/\/[\w\-_]+)((\.[\w\-_]+)+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?", "$1$2$3$5")
    	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>")
    	
    	strString = Replace(strString, "", "<span style=""font-weight: bold;"">")
    	strString = Replace(strString, "", "<span style=""font-weight: bold;"">")
    	strString = Replace(strString, "", "<span style=""text-decoration: underline;"">")
    	strString = Replace(strString, "", "<span style=""text-decoration: underline;"">")
    	strString = Replace(strString, "", "<span style="" font-style: italic;"">")
    	strString = Replace(strString, "", "<span style="" font-style: italic;"">")
    	strString = Replace(strString, "", "</span>")
    	strString = Replace(strString, "", "</span>")
    	strString = Replace(strString, "", "</span>")
    	strString = Replace(strString, "", "</span>")
    	strString = Replace(strString, "", "</span>")
    	strString = Replace(strString, "", "</span>")
    	strString = Replace(strString, "[/i]", "<ul>[*]")
    	strString = Replace(strString, "[LI]", "<ul>[*]")
    	strString = Replace(strString, "[Li]", "<ul>[*]")
    	strString = Replace(strString, "[lI]", "<ul>[*]")
    	strString = Replace(strString, "[/li]", "[/list]")
    	strString = Replace(strString, "[/LI]", "[/list]")
    	strString = Replace(strString, "[/Li]", "[/list]")
    	strString = Replace(strString, "[/lI]", "[/list]")
    	BBCodeToHTML = strString
    End Function
    
    
    message = BBCodeToHTML(request.form("textArea"))
    Quello che si registra nella textarea del forum è questo:


    <span style="font-weight: bold;">ciao</span>
    <span style=" font-style: italic;">bye</span>
    <span style="text-decoration: underline;">hola</span>
    [ quote ]eila[ /quote ]
    [ code ]ciccio[ /code ]
    http://www.google.it
    [ img ]daisy[ /img ]
    Problemi:

    - Non funzionano i tag code, quote e img;
    - Come faccio a rendere leggibile il BBCode nel form?

    Potreste aiutarmi per favore?
    Grazie

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Guarda le RegExp usate da imente per il suo WBCode: http://www.imente.it/scripts.asp?id=3

    Roby

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.