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

Posted by Captain Dondo on 06/15/05 18:39

I am trying to pull out an href from a bit of javascript. I am running
php, but the RE should be the same....

What I have is this:

<a href="JavaScript:void(0)"
onClick="JavaScript:window.open(\'http://www.seiner.com/blog/Travels/images/wp-snapshot.php?image=http://www.seiner.com/blog/Travels/images/2.jpg&width=730&height=755\',
\'FamilyPic\', \'scrollbars=yes,height=755,width=730,location=no\');
return false"><img
src="http://www.seiner.com/blog/Travels/images/thumb-2.jpg"/></a>

What I want to do is pull out the URL in the window.open call but only
if it doesn't contain either a next=[whatever] or a prev=[whatever] tag.

In other words, the above href doesn't contain either one, so my RE
returns 'http://www.seiner.com/blog/Travels/images/1.jpg'.

But if the above URL were to be as follows (see the next and prev at the
end of the URL):

<a href="JavaScript:void(0)"
onClick="JavaScript:window.open(\'http://www.seiner.com/blog/Travels/images/wp-snapshot.php?image=http://www.seiner.com/blog/Travels/images/2.jpg&width=730&height=755&prev=4.jpg&next=2.jpg\',
\'FamilyPic\', \'scrollbars=yes,height=755,width=730,location=no\');
return false"><img
src="http://www.seiner.com/blog/Travels/images/thumb-2.jpg"/></a>

I want the RE to not match....

The RE I am using is

$re = '<[aA] .*image=([a-zA-Z0-9.:/-]*).*/>';

and the actual match is done via:

preg_match_all ( $re, $text , $matches, PREG_OFFSET_CAPTURE);

TIA...

 

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

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