You are here: Re: Parsing HTML with Regular Expressions « HTML « IT news, forums, messages
Re: Parsing HTML with Regular Expressions

Posted by Gunnar Hjalmarsson on 06/16/05 00:49

Captain Dondo wrote:
> Gunnar Hjalmarsson wrote:
>> Captain Dondo wrote:
>>> I am running php, but the RE should be the same....
>>
>> Are you sure of that?
>
> Hopefully close enough to get me started....
>
>> $re = '<[aA][^>]+image=([a-zA-Z0-9.:/-]+)(?![^>]+(?:next|prev)=)';
>
> Close enough.... It's picking up the whole <a ... /a>

In Perl it does its job on the example snippets you posted. That's what
I meant when questioning that regular expressions are the same
irrespective of the programming language. You'd better not count on it.

> but I think it's enough to get me started....

The (?!...) construct is called a "zero-width negative look-ahead
assertion" in Perl.

> The [^>] rewinds the pattern match to the beginning of the line, I take it?

No. Jim explained what it means (and *that* is not Perl specific AFAIK).

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 

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

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