RE: [PHP] preg_replace pains
| From: | John Holmes | Date: | Fri, 28 Jun 2002 01:46:06 +0000 |
| Subject: | RE: [PHP] preg_replace pains | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104249@lists.php.net to get a copy of this message | ||
Wouldn't you want to use preg_match() before you replace it?
www.php.net/preg_match
---John Holmes...
> -----Original Message-----
> From: Richard Davey [mailto:rich@fatal-design.com]
> Sent: Thursday, June 27, 2002 9:37 PM
> To: php-general@lists.php.net
> Subject: [PHP] preg_replace pains
>
> Hi all,
>
> I've been having a wonderful night trying to solve this one, but I'm
going
> to throw in the towel and see if anyone else can shed some light on
it.
> The
> scenerio is quite simple, I'm parsing some form input from a user and
> looking for the following:
>
> [details].......[/details]
>
> where the .... can be any number of characters.
>
> All I want to do is remove the whole section, including the [details]
> part.
>
> So far I've got this working:
>
> $message = preg_replace("'\[details\].*?'", "", $message);
>
> Which manages to find the opening tags (and remove them) but as soon
as I
> try to capture the closing tag (and all inbetween) it goes horribly
wrong.
> My last attempt looked like this:
>
> $message = preg_replace("'\[details\].*?\[/details\]'", "",
> $message);
>
> This fails miserably. I'm fresh out of ideas and don't know enough
about
> regular expressions to be able to complete this task without some
> assistance. ANY comments welcome!
>
> Cheers,
>
> Richard
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php