Re: preg_replace help!

From: Date: Thu, 04 May 2006 02:30:07 +0000
Subject: Re: preg_replace help!
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-41811@lists.php.net to get a copy of this message
nevermind, I got it fixed. Just had to rearrange it. it was sensing the i in img as italic so if you put it first it would work. ----- Original Message ----- From: "Liber" <liber@iproom.com> To: "'Nathan Heaps'" <nathan42100@student.com>; "'John Hicks'" <johnlist@gulfbridge.net> Cc: <php-db@lists.php.net> Sent: Wednesday, May 03, 2006 10:17 PM Subject: RE: [PHP-DB] preg_replace help!
//     "/\[i(.*?)\](.*?)\[\/i(.*?)\]/",   // Italics
    "/\[u(.*?)\](.*?)\[\/u(.*?)\]/",   // Underline
    "/\[img(.*?)\](.*?)\[\/img(.*?)\]/",  // Image
    "/\[b(.*?)\](.*?)\[\/b(.*?)\]/");   // Bold
Change to
    "/\[i:(.*?)\](.*?)\[\/i:(.*?)\]/",   // Italics
    "/\[u:(.*?)\](.*?)\[\/u:(.*?)\]/",   // Underline
    "/\[img:(.*?)\](.*?)\[\/img:(.*?)\]/",  // Image
    "/\[b:(.*?)\](.*?)\[\/b:(.*?)\]/");   // Bold
-----Original Message----- From: Nathan Heaps [mailto:nathan42100@student.com] Sent: Thursday, May 04, 2006 8:08 AM To: John Hicks Cc: php-db@lists.php.net Subject: Re: [PHP-DB] preg_replace help! 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@gulfbridge.net> To: "Nathan Heaps" <nathan42100@student.com> Cc: <php-db@lists.php.net> Sent: Wednesday, May 03, 2006 7:46 PM Subject: Re: [PHP-DB] 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


« previous php.db (#41811) next »