Results 1 to 4 of 4

Thread: Does somebody know how to convert a big of PHP "eregi_replace" to VB code please?

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Does somebody know how to convert a big of PHP "eregi_replace" to VB code please?

    hi there people..

    I have this simple PHP code to allow people to use bold / italic / underlined etc text in guestbook's etc, via bbcode...

    PHP Code:
    <?php

    $code  
    "This is a string with lots of bb code stuff in";


    echo 
    "$code\n\n\n\n\n\n\n";

    echo 
    bbcode($code);


    function 
    bbcode($string) {

        
    // Image BB Code
        
    $string=eregi_replace("\\[img\\]([^\\[]*)\\[/img\\]","<img src=\"\\1\" border=0>",$string);

        
    // URL Hyperlink BB Code
        
    $string=eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=\"_blank\">\\1</a>",$string);
        
    $string=eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=\"_blank\">\\1</a>",$string);
        
    $string=eregi_replace("\\[url=www.([^\\[]+)\\]([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",$string);
        
    $string=eregi_replace("\\[url=http://([^\\[]+)\\]([^\\[]*)\\[/url\\]","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$string);

        
    // EMail Hyperlink BB Code
        
    $string=eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]","<a href=\"mailto:\\1\">\\1</a>",$string);
        
    $string=eregi_replace("\\[email=([^\\[]+)\\]([^\\[]*)\\[/email\\]","<a href=\"mailto:\\1\">\\2</a>",$string);

        
    // Font size and color BB Code
        
    $string=eregi_replace("\\[size=([^\\[]+)\\]([^\\[]*)\\[/size\\]","<font size=\"\\1\">\\2</font>",$string);
        
    $string=eregi_replace("\\[color=([^\\[]+)\\]([^\\[]*)\\[/color\\]","<font color=\"\\1\">\\2</font>",$string);

        
    // Text Formatting BB Code
        
    $string=eregi_replace("\\[b\\]([^\\[]*)\\[/b\\]","<b>\\1</b>",$string);
        
    $string=eregi_replace("\\[i\\]([^\\[]*)\\[/i\\]","<i>\\1</i>",$string);
        
    $string=eregi_replace("\\[u\\]([^\\[]*)\\[/u\\]","<u>\\1</u>",$string);

        return 
    $string;
    }

    ?>
    Now, i want to be able to use BB Code in a visual basic application, and am at a loss where to start with converting it really...

    i guess somebody has probally done something simular (and chances are, alot better) for their own applications, but, can somebody help me convert this code please?

    Thanks.
    Wayne

  2. #2
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692
    I'm just taking a guess here, as I don't know PHP as well as you probably do, but what you're doing sounds like you're taking out specific characters in a string.

    Try using the Replace function, see if it suits your needs. I don't know how to define multiple characters to replace though.

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    It's actually quite difficult to use regular expressions in vb

    If you know what you are trying to do, you could write a parse function to do it ;o

    [edit]

    gimme a minute
    Last edited by da_silvy; Sep 22nd, 2003 at 06:39 AM.

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    look into the regular expression engine with vbscript

    otherwise i'll write a parser for you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width