Page 1 of 1

extracting the content of alt from img

Posted: Sat Jan 09, 2010 12:29 pm
by vishok
i'd like to extract from a string like this :

<div id='pippo'><p><img src='pluto' alt='paperino'/><img src='pluto' alt='pippo'/><img src='pluto' alt='topolino'/></p></div>

a string like this :

paperino pluto topolino (only the content of the alt tag

How can i do this with php regex ?

Thanks i'm a newbie of regex

Re: extracting the content of alt from img

Posted: Sat Jan 09, 2010 1:23 pm
by AbraCadaver
This would probably work:

Code: Select all

/alt='([^']+)'/