• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

Unable to do both size and colour within my bbcode

Im using [size=36pt][color=red]test[/color][/size]
but my html output is :   <span id="Label1">[size=36pt]<font color="red">test</font>[/size]</span>


My bbcode is
Imports Microsoft.VisualBasic

Public Class BBcode

    Shared Function BBcode(ByVal strTextToReplace As String) As String

        '//Define regex
        Dim regExp As Regex

        '//Regex for URL tag without anchor
        regExp = New Regex("\[url\]([^\]]+)\[\/url\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<a href=""$1"">$1</a>")

        '//Regex for URL with anchor
        regExp = New Regex("\[url=([^\]]+)\]([^\]]+)\[\/url\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<a href=""$1"">$2</a>")

        '//Image regex
        regExp = New Regex("\[img\]([^\]]+)\[\/img\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<img src=""$1"" />")

        '//Bold text
        regExp = New Regex("\[b\](.+?)\[\/b\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<b>$1</b>")

        '//Italic text
        regExp = New Regex("\[i\](.+?)\[\/i\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<i>$1</i>")

        '//Underline text
        regExp = New Regex("\[u\](.+?)\[\/u\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<u>$1</u>")

        '//Font size
        regExp = New Regex("\[size=([^\]]+)\]([^\]]+)\[\/size\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<font size="" $1"">$2</font>")

        '//Font color
        regExp = New Regex("\[color=([^\]]+)\]([^\]]+)\[\/color\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<font color=""$1"">$2</font>")

        '//Quote
        regExp = New Regex("\[quote=([^\]]+)\]([^\]]+)\[\/quote\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<div class=""quote"" align=""left""><div align=""left"" class=""quotetitle"">Originally Posted by <b>$1</b></div><i>"" $2 ""</i></div>")
        '//smiles


        Return strTextToReplace
    End Function
End Class

Open in new window


anyhelp would be great
0
runnerjp2005
Asked:
runnerjp2005
  • 8
  • 5
  • 5
1 Solution
 
Carl BohmanCommented:
You are specifically not working if there are other square brackets involved: ("\[size=([^\]]+)\]([^\]]+)\[\/size\]")
While italics and some of the others allow square brackets in the middle: ("\[i\](.+?)\[\/i\]")

You are probably safe in using the .+? approach instead of the [^\]]+ approach.  One thing that neither of these handles is nesting, where one code is contained in another: [ i]first layer[ i]second layer[ /i]first layer[ /i]

(The spaces are there because EE tries to interpret those codes and doesn't allow nesting.)

A more generic approach might be to look for a begin tag and its matching end tag (with no tags in between) and then replace them.  Repeat until all tags are replaced.  This replaces all tags from the inside out.  It's more complicated to code something like that, but it can be used to find all matching tags.
0
 
käµfm³d 👽Commented:
Try this modification which *should* handle nested tags and should perform a tad bit better since I've used the Compiled option:
Public Class BBcode

    Private Shared bbCodeRegex As Regex
    Private Shared urlRegex As Regex
    Private Shared urlAnchorRegex As Regex
    Private Shared imgRegex As Regex
    Private Shared boldRegex As Regex
    Private Shared italicRegex As Regex
    Private Shared underRegex As Regex
    Private Shared fSizeRegex As Regex
    Private Shared fColorRegex As Regex
    Private Shared quoteRegex As Regex

    Shared Sub New()
        bbCodeRegex = New Regex("\[([^\]]+)\]((?:[^\[]|\[(?!/\1\]))+)\[/\1\]", RegexOptions.Compiled)
        urlRegex = New Regex("\[url\]([^\]]+)\[\/url\]", RegexOptions.Compiled)
        urlAnchorRegex = New Regex("\[url=([^\]]+)\]([^\]]+)\[\/url\]", RegexOptions.Compiled)
        imgRegex = New Regex("\[img\]([^\]]+)\[\/img\]", RegexOptions.Compiled)
        boldRegex = New Regex("\[b\]((?:[^\[]|\[(?!/b\]))+)\[/b\]", RegexOptions.Compiled)
        italicRegex = New Regex("\[i\]((?:[^\[]|\[(?!/i\]))+)\[\/i\]", RegexOptions.Compiled)
        underRegex = New Regex("\[u\]((?:[^\[]|\[(?!/u\]))+)\[\/u\]", RegexOptions.Compiled)
        fSizeRegex = New Regex("\[size=([^\]]+)\]((?:[^\[]|\[(?!/size\]))+)\[\/size\]", RegexOptions.Compiled)
        fColorRegex = New Regex("\[color=([^\]]+)\]((?:[^\[]|\[(?!/color\]))+)\[\/color\]", RegexOptions.Compiled)
        quoteRegex = New Regex("\[quote=([^\]]+)\]((?:[^\[]|\[(?!/quote\]))+)\[\/quote\]", RegexOptions.Compiled)
    End Sub

    Shared Function BBcode(ByVal strTextToReplace As String) As String

        While bbCodeRegex.IsMatch(strTextToReplace)
            '//Regex for URL tag without anchor
            strTextToReplace = urlRegex.Replace(strTextToReplace, "<a href=""$1"">$1</a>")

            '//Regex for URL with anchor
            strTextToReplace = urlAnchorRegex.Replace(strTextToReplace, "<a href=""$1"">$2</a>")

            '//Image regex
            strTextToReplace = imgRegex.Replace(strTextToReplace, "<img src=""$1"" />")

            '//Bold text
            strTextToReplace = boldRegex.Replace(strTextToReplace, "<b>$1</b>")

            '//Italic text
            strTextToReplace = italicRegex.Replace(strTextToReplace, "<i>$1</i>")

            '//Underline text
            strTextToReplace = underRegex.Replace(strTextToReplace, "<u>$1</u>")

            '//Font size
            strTextToReplace = fSizeRegex.Replace(strTextToReplace, "<font size="" $1"">$2</font>")

            '//Font color
            strTextToReplace = fColorRegex.Replace(strTextToReplace, "<font color=""$1"">$2</font>")

            '//Quote
            strTextToReplace = quoteRegex.Replace(strTextToReplace, "<div class=""quote"" align=""left""><div align=""left"" class=""quotetitle"">Originally Posted by <b>$1</b></div><i>"" $2 ""</i></div>")

            '//smiles
        End While

        Return strTextToReplace
    End Function
End Class

Open in new window

0
 
käµfm³d 👽Commented:
One caveat of the above:  If you have a BB code that you have included in your list of acceptable codes, then the loop will continue forever. You'll need to add some logic to check for non-legal BB codes.

For example, the following would cause an endless loop:
[size=36pt][helloworld]test[/helloworld][/size]

Open in new window

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
käµfm³d 👽Commented:
Actually, I withdraw my previous statement. It will not handle nested tags...   at least not properly. I'll give it some thought.
0
 
Carl BohmanCommented:
This version handles nested tags and unknown tags.  What it does not handle is unmatched tags.
Imports System.Text.RegularExpressions

Public Class BBcode

    Private Shared bbCodeRegex As Regex
    Private Shared bbUnknownRegex As Regex
    Private Shared urlRegex As Regex
    Private Shared urlAnchorRegex As Regex
    Private Shared imgRegex As Regex
    Private Shared boldRegex As Regex
    Private Shared italicRegex As Regex
    Private Shared underRegex As Regex
    Private Shared fSizeRegex As Regex
    Private Shared fColorRegex As Regex
    Private Shared quoteRegex As Regex

    Shared Sub New()
        bbCodeRegex = New Regex("\[(\w+)[^\]]*\]((?:[^\[]|\[(?!/\1\]))+)\[/\1\]", RegexOptions.Compiled)
        bbUnknownRegex = New Regex("\[(\w+)[^\]]*\]((?:[^\[]|\[(?!/\1\]))+)\[/\1\]", RegexOptions.Compiled)
        urlRegex = New Regex("\[url\]([^\]]+)\[\/url\]", RegexOptions.Compiled)
        urlAnchorRegex = New Regex("\[url=([^\]]+)\]([^\]]+)\[\/url\]", RegexOptions.Compiled)
        imgRegex = New Regex("\[img\]([^\]]+)\[\/img\]", RegexOptions.Compiled)
        boldRegex = New Regex("\[b\]((?:[^\[]|\[(?!/b\]))+)\[/b\]", RegexOptions.Compiled)
        italicRegex = New Regex("\[i\]((?:[^\[]|\[(?!/i\]))+)\[\/i\]", RegexOptions.Compiled)
        underRegex = New Regex("\[u\]((?:[^\[]|\[(?!/u\]))+)\[\/u\]", RegexOptions.Compiled)
        fSizeRegex = New Regex("\[size=([^\]]+)\]((?:[^\[]|\[(?!/size\]))+)\[\/size\]", RegexOptions.Compiled)
        fColorRegex = New Regex("\[color=([^\]]+)\]((?:[^\[]|\[(?!/color\]))+)\[\/color\]", RegexOptions.Compiled)
        quoteRegex = New Regex("\[quote=([^\]]+)\]((?:[^\[]|\[(?!/quote\]))+)\[\/quote\]", RegexOptions.Compiled)
    End Sub

    Shared Function BBcode(ByVal strTextToReplace As String) As String
        Dim mMatch As Match = bbCodeRegex.Match(strTextToReplace)

        While mMatch.Success
            Select Case mMatch.Groups(1).ToString
                Case "url"
                    '//Regex for URL tag without anchor
                    strTextToReplace = urlRegex.Replace(strTextToReplace, "<a href=""$1"">$1</a>")

                    '//Regex for URL with anchor
                    strTextToReplace = urlAnchorRegex.Replace(strTextToReplace, "<a href=""$1"">$2</a>")

                Case "img"
                    '//Image regex
                    strTextToReplace = imgRegex.Replace(strTextToReplace, "<img src=""$1"" />")

                Case "b"
                    '//Bold text
                    strTextToReplace = boldRegex.Replace(strTextToReplace, "<b>$1</b>")

                Case "i"
                    '//Italic text
                    strTextToReplace = italicRegex.Replace(strTextToReplace, "<i>$1</i>")

                Case "u"
                    '//Underline text
                    strTextToReplace = underRegex.Replace(strTextToReplace, "<u>$1</u>")

                Case "size"
                    '//Font size
                    strTextToReplace = fSizeRegex.Replace(strTextToReplace, "<font size="" $1"">$2</font>")

                Case "color"
                    '//Font color
                    strTextToReplace = fColorRegex.Replace(strTextToReplace, "<font color=""$1"">$2</font>")

                Case "quote"
                    '//Quote
                    strTextToReplace = quoteRegex.Replace(strTextToReplace, "<div class=""quote"" align=""left""><div align=""left"" class=""quotetitle"">Originally Posted by <b>$1</b></div><i>"" $2 ""</i></div>")

                Case Else
                    strTextToReplace = bbUnknownRegex.Replace(strTextToReplace, "$2")
            End Select

            mMatch = bbCodeRegex.Match(strTextToReplace)

        End While

        BBcode = strTextToReplace
    End Function
End Class

Open in new window

0
 
Carl BohmanCommented:
Actually, my code simply leaves unmatched tags alone without removing them.  If that's okay, then there's nothing else to do.  If you want to remove the unmatched tags, just do a final replace at the end that removes them.
0
 
runnerjp2005Author Commented:
bounsy: thats amazing...

Could i also ask if i where to add image to it how would i go about it??
<div align="center"><a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':',')'); return false"><img 
src="~/emoticons/smiley.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':','('); return false"><img 
src="~/emoticons/sad.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),';',')'); return false"><img 
src="~/emoticons/wink.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':','D'); return false"><img 
src="~/emoticons/cheesy.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),';','D'); return false"><img 
src="~/emoticons/grin.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),'::',')'); return false"><img 
src="~/emoticons/rolleyes.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),'>:','('); return false"><img 
src="~/emoticons/angry.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':','o'); return false"><img 
src="~/emoticons/shocked.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),'8',')'); return false"><img 
src="~/emoticons/cool.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),'??','?'); return false"><img 
src="~/emoticons/huh.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':','p'); return false"><img 
src="~/emoticons/tongue.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':-','['); return false"><img 
src="~/emoticons/embarrassed.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':-','*'); return false"><img 
src="~/emoticons/undecided.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':-','\\'); return false"><img 
src="~/emoticons/lipssealed.gif" border="0" alt=""/></a>
      <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':-','*'); return false"><img 
src="~/emoticons/kiss.gif" border="0" alt=""/></a>
    <a href="~/emoticons/smiley.gif" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':','*('); return false"><img 
src="~/emoticons/cry.gif" border="0" alt=""/></a></div>

Open in new window

0
 
Carl BohmanCommented:
img is already in there.  A quick glance around the web shows that there are a lot of different ways smileys are done in BBCode or other formats.  What is the format you want to convert/support?  Do you have any examples?
0
 
runnerjp2005Author Commented:
well i just want to convert :) into the imagelink so is uses the same princaple as the img file but has to show the :) = smiley.gif as shown above snippit
0
 
käµfm³d 👽Commented:
bounsy: thats amazing...
I agree. How on earth did you come up with all those fancy patterns...
0
 
runnerjp2005Author Commented:
kaufmed good point!

any idea how can do the smilie side

so
 :) would become <img src="happy.gif" alt="happy"/>
:( =  <img src="sad.gif" alt="sad"/>
;( =  <img src=cry.gif" alt="cry"/>

ect...
0
 
käµfm³d 👽Commented:
Those are easy. I would just do a regular string.Replace() on those.
0
 
Carl BohmanCommented:
I agree with kaufmed.  A series of string.Replace() would likely be the most straightforward.  Just make sure you start with the most complex and end with the least (in cases where it makes a difference, such as :-) vs *<:-) for example)
0
 
runnerjp2005Author Commented:
Would it be like this ??

Imports System.Text.RegularExpressions

Public Class BBcode

    Private Shared bbCodeRegex As Regex
    Private Shared bbUnknownRegex As Regex
    Private Shared urlRegex As Regex
    Private Shared urlAnchorRegex As Regex
    Private Shared imgRegex As Regex
    Private Shared boldRegex As Regex
    Private Shared italicRegex As Regex
    Private Shared underRegex As Regex
    Private Shared fSizeRegex As Regex
    Private Shared fColorRegex As Regex
    Private Shared quoteRegex As Regex
    Private Shared face As Regex

    Shared Sub New()
        bbCodeRegex = New Regex("\[(\w+)[^\]]*\]((?:[^\[]|\[(?!/\1\]))+)\[/\1\]", RegexOptions.Compiled)
        bbUnknownRegex = New Regex("\[(\w+)[^\]]*\]((?:[^\[]|\[(?!/\1\]))+)\[/\1\]", RegexOptions.Compiled)
        urlRegex = New Regex("\[url\]([^\]]+)\[\/url\]", RegexOptions.Compiled)
        urlAnchorRegex = New Regex("\[url=([^\]]+)\]([^\]]+)\[\/url\]", RegexOptions.Compiled)
        imgRegex = New Regex("\[img\]([^\]]+)\[\/img\]", RegexOptions.Compiled)
        boldRegex = New Regex("\[b\]((?:[^\[]|\[(?!/b\]))+)\[/b\]", RegexOptions.Compiled)
        italicRegex = New Regex("\[i\]((?:[^\[]|\[(?!/i\]))+)\[\/i\]", RegexOptions.Compiled)
        underRegex = New Regex("\[u\]((?:[^\[]|\[(?!/u\]))+)\[\/u\]", RegexOptions.Compiled)
        fSizeRegex = New Regex("\[size=([^\]]+)\]((?:[^\[]|\[(?!/size\]))+)\[\/size\]", RegexOptions.Compiled)
        fColorRegex = New Regex("\[color=([^\]]+)\]((?:[^\[]|\[(?!/color\]))+)\[\/color\]", RegexOptions.Compiled)
        quoteRegex = New Regex("\[quote=([^\]]+)\]((?:[^\[]|\[(?!/quote\]))+)\[\/quote\]", RegexOptions.Compiled)
        face = New Regex(":)", RegexOptions.Compiled)
    End Sub

    Shared Function BBcode(ByVal strTextToReplace As String) As String
        Dim mMatch As Match = bbCodeRegex.Match(strTextToReplace)

        While mMatch.Success
            Select Case mMatch.Groups(1).ToString
                Case "url"
                    '//Regex for URL tag without anchor
                    strTextToReplace = urlRegex.Replace(strTextToReplace, "<a href=""$1"">$1</a>")

                    '//Regex for URL with anchor
                    strTextToReplace = urlAnchorRegex.Replace(strTextToReplace, "<a href=""$1"">$2</a>")

                Case "img"
                    '//Image regex
                    strTextToReplace = imgRegex.Replace(strTextToReplace, "<img src=""$1"" />")

                Case "b"
                    '//Bold text
                    strTextToReplace = boldRegex.Replace(strTextToReplace, "<b>$1</b>")

                Case "i"
                    '//Italic text
                    strTextToReplace = italicRegex.Replace(strTextToReplace, "<i>$1</i>")

                Case "u"
                    '//Underline text
                    strTextToReplace = underRegex.Replace(strTextToReplace, "<u>$1</u>")

                Case "size"
                    '//Font size
                    strTextToReplace = fSizeRegex.Replace(strTextToReplace, "<font size="" $1"">$2</font>")

                Case "color"
                    '//Font color
                    strTextToReplace = fColorRegex.Replace(strTextToReplace, "<font color=""$1"">$2</font>")

                Case "quote"
                    '//Quote
                    strTextToReplace = quoteRegex.Replace(strTextToReplace, "<div class=""quote"" align=""left""><div align=""left"" class=""quotetitle"">Originally Posted by <b>$1</b></div><i>"" $2 ""</i></div>")
                Case ":)"
                    strTextToReplace = face.Replace(strTextToReplace, "smile")
                Case Else
                    strTextToReplace = bbUnknownRegex.Replace(strTextToReplace, "$2")
            End Select

            mMatch = bbCodeRegex.Match(strTextToReplace)

        End While

        BBcode = strTextToReplace
    End Function
End Class

Open in new window

0
 
käµfm³d 👽Commented:
Don't use a new regex object...  just do a string replace:
Imports System.Text.RegularExpressions

Public Class BBcode

    Private Shared bbCodeRegex As Regex
    Private Shared bbUnknownRegex As Regex
    Private Shared urlRegex As Regex
    Private Shared urlAnchorRegex As Regex
    Private Shared imgRegex As Regex
    Private Shared boldRegex As Regex
    Private Shared italicRegex As Regex
    Private Shared underRegex As Regex
    Private Shared fSizeRegex As Regex
    Private Shared fColorRegex As Regex
    Private Shared quoteRegex As Regex

    Shared Sub New()
        bbCodeRegex = New Regex("\[(\w+)[^\]]*\]((?:[^\[]|\[(?!/\1\]))+)\[/\1\]", RegexOptions.Compiled)
        bbUnknownRegex = New Regex("\[(\w+)[^\]]*\]((?:[^\[]|\[(?!/\1\]))+)\[/\1\]", RegexOptions.Compiled)
        urlRegex = New Regex("\[url\]([^\]]+)\[\/url\]", RegexOptions.Compiled)
        urlAnchorRegex = New Regex("\[url=([^\]]+)\]([^\]]+)\[\/url\]", RegexOptions.Compiled)
        imgRegex = New Regex("\[img\]([^\]]+)\[\/img\]", RegexOptions.Compiled)
        boldRegex = New Regex("\[b\]((?:[^\[]|\[(?!/b\]))+)\[/b\]", RegexOptions.Compiled)
        italicRegex = New Regex("\[i\]((?:[^\[]|\[(?!/i\]))+)\[\/i\]", RegexOptions.Compiled)
        underRegex = New Regex("\[u\]((?:[^\[]|\[(?!/u\]))+)\[\/u\]", RegexOptions.Compiled)
        fSizeRegex = New Regex("\[size=([^\]]+)\]((?:[^\[]|\[(?!/size\]))+)\[\/size\]", RegexOptions.Compiled)
        fColorRegex = New Regex("\[color=([^\]]+)\]((?:[^\[]|\[(?!/color\]))+)\[\/color\]", RegexOptions.Compiled)
        quoteRegex = New Regex("\[quote=([^\]]+)\]((?:[^\[]|\[(?!/quote\]))+)\[\/quote\]", RegexOptions.Compiled)
    End Sub

    Shared Function BBcode(ByVal strTextToReplace As String) As String
        Dim mMatch As Match = bbCodeRegex.Match(strTextToReplace)

        While mMatch.Success
            Select Case mMatch.Groups(1).ToString
                Case "url"
                    '//Regex for URL tag without anchor
                    strTextToReplace = urlRegex.Replace(strTextToReplace, "<a href=""$1"">$1</a>")

                    '//Regex for URL with anchor
                    strTextToReplace = urlAnchorRegex.Replace(strTextToReplace, "<a href=""$1"">$2</a>")

                Case "img"
                    '//Image regex
                    strTextToReplace = imgRegex.Replace(strTextToReplace, "<img src=""$1"" />")

                Case "b"
                    '//Bold text
                    strTextToReplace = boldRegex.Replace(strTextToReplace, "<b>$1</b>")

                Case "i"
                    '//Italic text
                    strTextToReplace = italicRegex.Replace(strTextToReplace, "<i>$1</i>")

                Case "u"
                    '//Underline text
                    strTextToReplace = underRegex.Replace(strTextToReplace, "<u>$1</u>")

                Case "size"
                    '//Font size
                    strTextToReplace = fSizeRegex.Replace(strTextToReplace, "<font size="" $1"">$2</font>")

                Case "color"
                    '//Font color
                    strTextToReplace = fColorRegex.Replace(strTextToReplace, "<font color=""$1"">$2</font>")

                Case "quote"
                    '//Quote
                    strTextToReplace = quoteRegex.Replace(strTextToReplace, "<div class=""quote"" align=""left""><div align=""left"" class=""quotetitle"">Originally Posted by <b>$1</b></div><i>"" $2 ""</i></div>")
                Case Else
                    strTextToReplace = bbUnknownRegex.Replace(strTextToReplace, "$2")
            End Select

            mMatch = bbCodeRegex.Match(strTextToReplace)

        End While

        strTextToReplace = strTextToReplace.Replace(":)", "<img src=""happy.gif"" alt=""happy""/>")
        strTextToReplace = strTextToReplace.Replace(":(", "<img src=""sad.gif"" alt=""sad""/>")
        strTextToReplace = strTextToReplace.Replace(";(", "<img src=""cry.gif"" alt=""cry""/>")
        
        BBcode = strTextToReplace
    End Function
End Class

Open in new window

0
 
runnerjp2005Author Commented:
hey kaufmed.. Where is the single replace in the code above??
0
 
käµfm³d 👽Commented:
Lines 78, 79, and 80--one for each smiley.
0
 
käµfm³d 👽Commented:
Not to sound ungrateful, but bounsy did help with the switch statement  and the nested tags  : )
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 8
  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now