SunQuest
 
           Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old December 4th, 2005, 01:04 PM
baseballdude_'s Avatar
baseballdude_ baseballdude_ is offline
Expert Learner
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2005
Location: Wisconsin
Posts: 1,856 baseballdude_ User rank is Sergeant Major (2000 - 5000 Reputation Level)baseballdude_ User rank is Sergeant Major (2000 - 5000 Reputation Level)baseballdude_ User rank is Sergeant Major (2000 - 5000 Reputation Level)baseballdude_ User rank is Sergeant Major (2000 - 5000 Reputation Level)baseballdude_ User rank is Sergeant Major (2000 - 5000 Reputation Level)baseballdude_ User rank is Sergeant Major (2000 - 5000 Reputation Level)  Folding Points: 22104 Folding Title: Starter FolderFolding Points: 22104 Folding Title: Starter Folder
Time spent in forums: 1 Week 5 Days 9 h 30 m 59 sec
Reputation Power: 45
Send a message via AIM to baseballdude_ Send a message via MSN to baseballdude_ Send a message via Yahoo to baseballdude_ Send a message via Google Talk to baseballdude_
Simple BBCode Script

I created this BBCode script and thought I'd share it with everyone.
Code:
<%

'----------------------------------------
' 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>")
	strString = Replace(strString, "[b]", "<span style=""font-weight: bold;"">")
	strString = Replace(strString, "[B]", "<span style=""font-weight: bold;"">")
	strString = Replace(strString, "[u]", "<span style=""text-decoration: underline;"">")
	strString = Replace(strString, "[U]", "<span style=""text-decoration: underline;"">")
	strString = Replace(strString, "[i]", "<span style="" font-style: italic;"">")
	strString = Replace(strString, "[I]", "<span style="" font-style: italic;"">")
	strString = Replace(strString, "[/b]", "</span>")
	strString = Replace(strString, "[/B]", "</span>")
	strString = Replace(strString, "[/u]", "</span>")
	strString = Replace(strString, "[/U]", "</span>")
	strString = Replace(strString, "[/i]", "</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

'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

%>

To test it:
Code:
<%

strTest = "blah blah http://www.thisisaurl.com blah blah [color=orange]Orange Text[/color] blah blah [size=7]Size 7 Text[/size] blah blah [font=Arial]Arial Font[/font] blah blah [quote=BBD]This is what BBD said.[/quote] blah blah [b]Bold Text[/b] blah blah [u]Underlined Text[/u] blah blah [i]Italicized Text[/i] blah blah [li]Listed Text[/li] blah blah"

strOutput = BBCodeToHTML(strTest)

Response.Write(strOutput)

%>

Notes:
  • URL's are automatically turned into anchors.
  • All but colors, fonts, sizes, and quotes are not case sensitive for now.
  • You'll want to create CSS classes for .quote and .quote1 and style them however you wish.

Last edited by baseballdude_ : December 4th, 2005 at 01:31 PM.

Reply With Quote
  #2  
Old February 25th, 2008, 08:22 AM
Computer-bot Computer-bot is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 392 Computer-bot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 5 h 46 m 58 sec
Reputation Power: 2
baseball dude, have you extended this code any further?

CB

Reply With Quote
  #3  
Old March 9th, 2008, 11:37 AM
ArtJunky ArtJunky is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 87 ArtJunky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 39 m 9 sec
Reputation Power: 3
This is interesting

Last edited by ArtJunky : March 9th, 2008 at 11:40 AM.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Simple BBCode Script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway