You are here: Re: PHP and regular expressions « PHP Programming Language « IT news, forums, messages
Re: PHP and regular expressions

Posted by Rik on 03/02/07 18:17

On Fri, 02 Mar 2007 18:16:38 +0100, Damo <cormacdebarra@gmail.com> wrote=
:

> I'm slowly getting the hang of regex's, Instead ive starting a new
> thread i thought id ask here. I have this regex:
>
> $regexp =3D "%<li><a href=3D\"(.+?)\">.+[^>]+>([^<]+)</a>.+<span class=
=3D

-------------------------------------^greedy dot--------^again

> \"date\">(.+?)</span>.+<div class=3D\"abstract\">(.+?)</div>%s";

------------------------^greedy dot

> It matches a the URL of a link, the text of a link, a date and the
> abstract of a story.
> If I use preg_match_all and theres multiple matches to the pattern in=

> a html string, it inly stores the last one in $matches

$regexp =3D '%<li>\s*
<a[^>]*?href=3D"([^"]+)"[^>]*>
(.*?)
</a>
..*?
<span[^>]*?class=3D"date"[^>]*>
(.+?)
</span>
..+?
<div[^>]*?class=3D"abstract"[^>]*>
(.+?)
</div>%six';

-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация