Re: How to write a simple parser?
| From: | Folke Ashberg | Date: | Tue, 28 Nov 2000 00:12:04 +0000 |
| Subject: | Re: How to write a simple parser? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27516@lists.php.net to get a copy of this message | ||
Hi!
use eregi_replace!
for example
$erg=eregi_replace("\[link:(.+)|(.*)\]","<A
HREF=\"\\1\">\\2</A>",$input);
Also refer to http://www.php.net/manual/function.strip-tags.php
ans set allowable_tags
$erg=strip_tags($input,"<A>,<BR>,<ALSO_THIS_TAG");
then users can enter HTML as usal.
Btw: are you going to clone the UBB-Forum? :)
regards
folke
--
Folke Ashberg
Stage Internet Services GmbH
Technical Development
folke@fanstage.de
folke@fanstage.de | Tel: +49 89 454591-77 | Fax: +49 89 454591-71
Kreillerstr. 21 | 81673 Munich | Germany | www.fanstage.de
On Mon, 27 Nov 2000, rodrigo wrote:
> I neeed to write a simple parser that will interpret simple commands and
> convert them to HTML. The command tags start and end with square
> brackets "[]". For example, if someone where to type
> "[link:www.locatio.com | locatio]" then that would translate into "<a
> href="www.locatio.com">locatio</a>".
>
> It is just a way for users to avoid doing any HTML at all. I tried the
> regular expression functions but they only return a TRUE/FALSE value. I
> would like to be able to return the first part of the string, which has
> the command in it.
>
> Thanks in advance.
>