Reputation: 2663
alt="Abdul Aziz" width="75" height="75" class="thumb-border"></td>
I want to select "Abdul Aziz" from the html above. How should I do this? It must be generic as I have to select many names from similar looking HTML.
Upvotes: 0
Views: 103
Reputation: 5438
Using Javascript would be more consistent:
//You can get elements by tag :
els = document.getElementsByTag('td');
// or you can get elements by class name :
els = document.getElementsByClassName('thumb-border');
and then iterate through your elements and read the alt attribute.
or if using jQuery you can use selector:
http://api.jquery.com/category/selectors/
Upvotes: 0
Reputation: 7960
alt="[\w\s]+"
Will select the whole statement, and then you can remove the alt and quotes with your code.
Upvotes: 1
Reputation: 9500
Not sure what language you are using, but here's a pattern that would start to get you there. Beware that parsing HTML with regexes has all sorts of downsides.
"/alt=\"(.*?)\".*?>/"
This will retrieve the stuff between alt="" into the first capture group.
Upvotes: 1