Re: Pb'lm of Regular Expression

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

 



ankur_os@xxxxxxxxxxxx wrote:
thnx for your support every thing is working well but still one problem, that height and width are not coming so how i modify the
first regular exp. so it shows both height and width.
********************************
/<img\s+.*?src="(.*?)".*?>/s
********************************

I'm not sure if I understand you. Do you want the complete tag with all attributes? The above regex already provides this data in the first index of the matches-array. Or do you want to explicitly fetch the width and height of an image tag. Then you just need to replace "src" with "width" or whatever attribute you want in the above regex. You can also read multiple attributes with one regex but then you are limited to a specific attribute order. So it will not work for pages which are not under you control.


A better solution is to do it in multiple steps:

1. Match the complete tag: /<img.*?>/s

2. Match the attribs in the tag: /(\w+)="(.*?)"/s

3. Iterate over the matches of step 2 and search the attribute you need.

--
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