|
-
Sep 22nd, 2003, 04:00 AM
#1
Thread Starter
Frenzied Member
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.
-
Sep 22nd, 2003, 06:06 AM
#2
Fanatic Member
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.
-
Sep 22nd, 2003, 06:31 AM
#3
Conquistador
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.
-
Sep 22nd, 2003, 08:47 AM
#4
Conquistador
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|