Sophie Mattoug wrote:
> Adam i Agnieszka Gasiorowski FNORD wrote:
>
>> I'm trying to develop a regex for matching with preg_match_all, I
>> want to match such things like image name, image alt text, image
>> title in construct like this:
>>
>> ....html...
>> <div class="class" style="style">
>> <img src="img=name" alt="alt" title="title" /> <span class="class"
>> style="style"> text
>> </span>
>> </div>
>> ....html...
>> The rexex as for now is:
>>
>> define(
>> 'REGEX_IMAGE_NAMES_AND_TITLES_AND_ALTS_FROM_CONTENT',
>> '{ (?:<\s*img\s+src\s*=\s*(?:"|\')?\s*(?:img)?\s*=\s*)
> # <img>
>> (?>\b\S+\b)
> # name
>> (?:title\s*=\s*(?:"|\'))
> # title
>> (?>\b\S*\b)
>> (?:"|\')*\s*
>> (?:alt\s*=\s*(?:"|\'))
> # alt
>> (?>\b\S*\b)
>> (?:"|\')*\s*
>> (?:\"|\'|>|/>|\s)
> # <img />
>> }Uix'
>> );
>>
My approach would be "somewhat something good from both worlds" it IS
possible to match an entire image tag with preg_match_all:
/<img (\s*(alt|src|style|title|name)=\s*"([^"]*)"\s*)*\/?>/i
Of course, this is not tested .. but should come at least a bit close to
what you want ...
Wouter
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php