Skip to content

Instantly share code, notes, and snippets.

@wikimo
Created October 20, 2014 08:33
Show Gist options
  • Save wikimo/d9fe68dab5748006c681 to your computer and use it in GitHub Desktop.
Save wikimo/d9fe68dab5748006c681 to your computer and use it in GitHub Desktop.
Regexp html img tag
str = <<EOF
<li class="cc">
<a href="#" class="cover">
<img src="public/images/food-1.png" alt=""></a>
<div class="info">
<h1>Food One</h1>
</div>
</li>
<li class="cc">
<a href="#" class="cover">
<img width="80" src="public/images/food-2.png" alt="test"></a>
<div class="info">
<h1>Food Two</h1>
</div>
</li>
EOF
result = str.scan(/(<img [^>]*src=['"]([^'"]+)[^>]*>)/)
p result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment