Re: unexpected '@' in preg_replace??? - SOLVED
| From: | Zoltán Németh | Date: | Tue, 30 Oct 2007 07:41:56 +0000 |
| Subject: | Re: unexpected '@' in preg_replace??? - SOLVED | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263799@lists.php.net to get a copy of this message | ||
2007. 10. 29, hétfő keltezéssel 09.17-kor Jim Lucas ezt írta:
> Daniel Brown wrote:
> > On 10/29/07, Zoltán Németh <znemeth@alterationx.hu> wrote:
> >> hi list,
> >>
> >> I have this code:
> > [snip!]
> >> Parse error: syntax error, unexpected '@'
> >> in /home/znemeth/public_html/test/pregreplacetest1.php(94) : regexp code
> >> on line 1
> >>
> >> Fatal error: preg_replace() [<a
> >> href='function.preg-replace'>function.preg-replace</a>]: Failed
> >> evaluating code: _nemeth@moveonerelo.com_
> >> in /home/znemeth/public_html/test/pregreplacetest1.php on line 94
> > [snip=again!]
> >
> > Zoltan,
> >
> > If you're using preg_replace(), where are your start and stop
> > characters for the pattern and subject?
> >
> > $szoveg =
> > preg_replace('/'.$mit.'/','/'.$mire.'/',$dokumentum);
> >
> > You could otherwise try ereg_replace(); without the slashes, or do
> > an htmlentities($dokumentum);.
> >
>
> Look again and you will notice that $mit and $mire are both arrays.
>
> Also, the starting and stopping points are in the $mit array elements.
>
> The starting and stopping points are not allowed in the $mire array.
>
> This was the offending line in the code. I removed the e from the modifiers list and it
> started
> working. See if you can run the code without it.
>
> '/<strong[^>]*>(.*?)<\/strong>/i', // <strong>
many thanks Jim, it solved the issue
>
>
> you missed your closing option
> '/<\/?p[^>]*>/i', // <P>
>
> or maybe you should have a different entry to remove the </p> and replace it with
> nothing.
> this
> '/<p[^>]*>/i', // <P>
> that
> "\n\n\t",
>
> this
> '/<\/p[^>]*>/i', // </P>
> that
> '',
thanks for this also, I added it
>
> Side note, you might want to look into using the '+' instead of the '*'.
> '+' = must be one or more
> '*' = 0 or more
>
> In some of the cases here, I see where this can bite you in the butt later.
>
thanks for the tip, I will look at it
greets
Zoltán Németh
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare
>