extracting the content of alt from img

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
vishok
Forum Newbie
Posts: 1
Joined: Sat Jan 09, 2010 12:26 pm

extracting the content of alt from img

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: extracting the content of alt from img

Post by AbraCadaver »

This would probably work:

Code: Select all

/alt='([^']+)'/
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply