I am trying to capture img tag in HTML using Regex…
So these must be captured:
<img/>
< img id = "f" />
I have used:
"<\s*img(\s.*?)?/>"
But this goes wrong:
< img id = "/>" />
Any idea how to probably capture img tag??
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
On a serious note: Use an xml parser instead.
Also, you should look into using a regex testing suite like regex buddy.
This might be a good read as well: RegEx match open tags except XHTML self-contained tags