Re: preg_replace help!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wait, its a different thing now. You see, I am trying to replace phpbb's bbcode with working html code, but what makes it hard is that phpbb inserts a number after SOME of the bbcode tags. Here is what I have so far:
function bbcodereplace($subject){
$search = array ("/\[url=(\W?)(.*?)(\W?)\](.*?)\[\/url\]/",
//     "/\[i(.*?)\](.*?)\[\/i(.*?)\]/",   // Italics
    "/\[u(.*?)\](.*?)\[\/u(.*?)\]/",   // Underline
    "/\[img(.*?)\](.*?)\[\/img(.*?)\]/",  // Image
    "/\[b(.*?)\](.*?)\[\/b(.*?)\]/");   // Bold
//                 '@&(gt|#62);@i',
//                 '@&(nbsp|#160);@i',
//                 '@&(iexcl|#161);@i',
//                 '@&(cent|#162);@i',
//                 '@&(pound|#163);@i',
//                 '@&(copy|#169);@i',
//                 '@&#(\d+);@e');                    // evaluate as php

$replace = array ('<a href="$2">$4</a>',
//         '<i>$2</i>',
        '<u>$2</u>',
        '<img src="$2">',
        '<b>$2</b>');
//                 '<u>',
//                 '<i>',
//                 '</u>',
//                 '</i>');
//                 '>',
//                 ' ',
//                 chr(161),
//                 chr(162),
//                 chr(163),
//                 chr(169),
//                 'chr(\1)');

return preg_replace($search, $replace, $subject);
}

my problem is that if I un-comment the italic thing, then image doesn't work. any idea on how to fix it? ----- Original Message ----- From: "John Hicks" <johnlist@xxxxxxxxxxxxxx>
To: "Nathan Heaps" <nathan42100@xxxxxxxxxxx>
Cc: <php-db@xxxxxxxxxxxxx>
Sent: Wednesday, May 03, 2006 7:46 PM
Subject: Re:  preg_replace help!


Nathan Heaps wrote:
I am trying to parse a forum post using php, but it parses it everytime it
sees the letter, not the thing in quotes.

What letter?  What thing in quotes?

-J

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux