Re: PCRE Problem
| From: | James Clifford | Date: | Thu, 13 Jun 2002 23:27:15 +0000 |
| Subject: | Re: PCRE Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-102104@lists.php.net to get a copy of this message | ||
On Thu, Jun 13, 2002 at 03:49:00PM +0100, Brian McGarvie wrote:
> $string = '[b]Test[/b]';
> $bbcode_string = str_replace("<", "[", str_replace(">",
> "]", $string));
>
> or look into regular expressions...
It's probably better to do as Brian suggests: use regular expressions so
that you can avoid cases like
[b onMouseOver="executesomejavascript"]Test[/b]
With something like
$bbcode_string = preg_replace("/\[(\/?)b\]/i", "<$1b>", $string);
> > -----Original Message-----
> > From: Erick Lee [mailto:webmaster@pczonehk.com]
> > Sent: 13 June 2002 3:25 AM
> > To: php-general@lists.php.net
> > Subject: [PHP] PCRE Problem
> >
> >
> >
> > I want to change it to
> > $string = <b>Test</b>
> > How?
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
James Clifford
james@base2.org