I use the same regex with grep
and it gives me a match but when doing it in a bash script, it return no match.
Test String(part of the file testregex.txt
):
<a href="/os_x_lynx-wallpapers.html"><p>OS X Lynx</p>
<img src="/thumbs/os_x_lynx-t1.jpg"
alt="OS X Lynx" class="thumb_img" width="270" height="169"/></a></div><div style="float:right;margin-right:13px;"></div></div>
This command correctly matches the highlighted part(and a few more):
grep -E '<img src="[^"]*\.jpg"' testregex.txt
But this bash script returns no match:
page=$(<testregex.txt)
if [[ $page =~ '<img src="[^"]*\.jpg"' ]]; then
echo $1
echo "match found"
else
echo "match not found!"
fi
-E
switch forgrep