Re: Re: One more Regular Expression Question...
| From: | Brad Melendy | Date: | Tue, 14 May 2002 16:26:02 +0000 |
| Subject: | Re: Re: One more Regular Expression Question... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97569@lists.php.net to get a copy of this message | ||
Thanks Miguel,
I'm going to check out preg_match(). What if there are more than one
instance of <a> and </a> in my string, but I know that I want the last two
occurances at the end. Can I tell it to check starting at the end of the
string and work forwards? Thanks again!
...Brad
"Miguel Cruz" <mnc@stoic.net> wrote in message
news:Pine.LNX.4.44.0205140232140.17387-100000@stoic.net...
> Preg is more flexible than ereg.
>
> if (preg_match('/\<a.*?\>(.+?)\<\/a/', $string1, $matches))
> print "Matched: {$matches[1]}";
>
> That'll just get what's between the <a> and </a>.
>
> http://php.net/preg_match for more info.
>
> miguel
>
> On Mon, 13 May 2002, Brad Melendy wrote:
> > Thanks Philip. This gives me everything before the "'>" that I'm
looking
> > for but I believe it is because it occurs more than once. I think I
need to
> > count the times that "'>" occurs and then try to target the specific
> > occurance that I need. But I'm guessing a little. Thanks for your
help.
> >
> > ...Brad
> >
> > "Philip Hallstrom" <philip@adhesivemedia.com> wrote in message
> >
> > news:20020513171017.B45180-100000@cypress.adhesivemedia.com...
> > >
> > > $string1 = "<a href='/Schedule_Detail'>Here's the
> > > Schedule</a>";
> > > ereg(">(.*)</a>", $string1, $matches);
> > > $string2 = $matches[1];
> > >
> > > Something close to that anyway...
> > >
> > > On Mon, 13 May 2002, Brad Melendy wrote:
> > >
> > > > Hello,
> > > > I'm pretty stuck here. I wish to assign a variable the value of a
> > > > particular substrint of text from a second variable. It's HTML so
I've
> > got
> > > > something like:
> > > >
> > > > $string1 = "<a href='/Schedule_Detail'>Here's the
> > > > Schedule</a>"
> > > >
> > > > I want to create a variable $string2 and assign it the value of
whatever
> > is
> > > > between ">" and "</a>". I just can't figure
> > > > out how to do that.
> > > >
> > > > Any kind souls want to give me a hand up? Thanks very much in
advance.
> > > >
> > > > ...Brad
> > > >
> > > > PS. I do have a PHP book and I did try reading up on regular
> > expressions at
> > > > php.net first, but I'm just not getting it. :-\
> > > >
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit:
> > > > http://www.php.net/unsub.php
> > > >
> > >
> >
> >
> >
> >
>
>