Re: preg_replace - regex for replace string
| From: | James Taylor | Date: | Wed, 27 Mar 2002 22:59:11 +0000 |
| Subject: | Re: preg_replace - regex for replace string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90445@lists.php.net to get a copy of this message | ||
Hm, nevermind my question :) I'm not thinking straight, not enough sleep.
On Wednesday 27 March 2002 02:53 pm, you wrote:
> On Wed, 27 Mar 2002, James Taylor wrote:
> > On Wednesday 27 March 2002 02:49 pm, you wrote:
> >> On Wed, 27 Mar 2002, James Taylor wrote:
> >>> I'm trying to do something to the effect of this for a preg_replace
> >>> statement:
> >>>
> >>> $string = "Hello\n\n\n\n\n\n\nHow are you?\n\n\n\n\n\n\n\nHi";
> >>> $string = preg_replace("/\n\n/", "/\n/", $string);
> >>>
> >>>
> >>> But, it appears the 'replace' portion of the function doesn't allow
> >>> for
> >>> regex. How can I do this so that I CAN have the second statement be
> >>> regex?
> >>
> >> I think you just have your syntax messed up. You don't need delimiters
> >> around the second argument.
> >>
> >> $string = preg_replace("/\n\n/", "\n", $string);
> >
> > This is just an example. There are some cases where I need the second
> > option to be a regular expression, the same way that you can do in Perl
> > regex...
>
> Regular expressions are for matching. Can you provide an example that
> illustrates what you're trying to do?
>
> miguel