Re: extract Occurrences AFTER ... and before "-30-"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Sep 2, 2012 at 6:23 AM, John Taylor-Johnston
<jt.johnston@xxxxxxxxxxxxxx> wrote:
> See:
> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.php
> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.phps
>
> In $mystring, I need to extract everything between "|News Releases|" and
> "-30".
>
> The thing now is $mystring might contain many instances of "|News Releases|"
> and "-30".
>
> How do I deal with this? My code only catches the first instance.
>
> Thanks for you help so far.
>
> John
>

You could use substr to retrieve the rest of the string and just start
over (do it in a while loop to catch all).
Though, it's probably not really efficient if you have long strings.
You'd be better off with preg_match. You can do it all with a single
line of code, albeit that regex takes quite some time to figure out if
not experienced.

- Matijn

PS. Please don't top post on this and probably any mailing list.

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux