Well I can explain that at least.  You have to cancel the delimiting
character if you're using it as a litteral within the exoression by
preceeding them with a \ slash...

"/\//"

"/(\")(.(\/))*[A-Z0-9_\/-]+(.gif|.jpg)/"

Otherwise you're ending the expression at the second slash.

-Kevin

----- Original Message -----
From: "Jennifer Swofford" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 01, 2002 3:03 PM
Subject: Re: [PHP] eregi_replace / preg_match_all


> Thanks Kevin -
>
> Actually, I'm confused about that too, because this
> does NOT work (delimeter):
>
> $contents =
> eregi_replace("/(\")(.(/))*[A-Z0-9_/-]+(.gif|.jpg)/",
> "\"blah.gif", $contents);
>
> But this does (no delimeter):
>
> $contents =
> eregi_replace("(\")(.(/))*[A-Z0-9_/-]+(.gif|.jpg)",
> "\"blah.gif", $contents);
>
> So I use the line of code without the delimeters.
> Which was my first hint that something might be wacky.
>  ;)
>
> But the preg_match_all code (below) doesn't work with
> or without the delimeters.
>
> I'm clearly new with regular expressions, but have
> been working on this all day and need some outside
> eyes.  8)
>
> Thanks again,
> Jen
>
> --- Kevin Stone <[EMAIL PROTECTED]> wrote:
> > Unknown modifier definitely has to do with the
> > regular expression. Don't
> > regex's need a beginning and ending delimeter apart
> > from the quote?
> >
> > "/(\")(.(\/))*[A-Z0-9_\/-]+(.gif|.jpg)/"
> >
> > Maybe that's it?  But if so I dunno why the other
> > one would be working.
> >
> > -Kevin
> >
> > ----- Original Message -----
> > From: "Jennifer Swofford" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, October 01, 2002 2:20 PM
> > Subject: [PHP] eregi_replace / preg_match_all
> >
> >
> > > Why does this work:
> > >
> > > $contents =
> > >
> > eregi_replace("(\")(.(/))*[A-Z0-9_/-]+(.gif|.jpg)",
> > > "\"blah.gif", $contents);
> > >
> > > But this does not:
> > >
> > >
> > preg_match_all("(\")(.(/))*[A-Z0-9_/-]+(.gif|.jpg)",
> > > $contents, $matches);
> > >
> > > for ($i=0; $i< count($matches[0]); $i++) {
> > > echo "matched: ".$matches[0][$i]."\n"
> > > }
> > >
> > > I get this error:
> > >
> > > Warning: Unknown modifier '(' in
> > > /home/littleduck/www/www/newcontrol/temp/fread.php
> > on
> > > line 20
> > >
> > > The first example finds/replaces fine.  The second
> > > does not find at all.  (If I replace the regular
> > > expression string with something simple like
> > > "(gif|jpg)" it works.)
> > >
> > > Thank you for any hints!
> > > Jen
> > >
> > >
> > > __________________________________________________
> > > Do you Yahoo!?
> > > New DSL Internet Access from SBC & Yahoo!
> > > http://sbc.yahoo.com
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit:
> > http://www.php.net/unsub.php
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to