Reputation: 39374
I am new to iPhone development. I am using RegexkitLite framework to parse and retrieve the particular content from the Html source. I want to retrieve the content in the attribute tag. How should I give regex to achieve it? The Tag is
<a href="http://www.stackoverflow.com" class="11-link-dkred-bold">This is stack overflow HTML</a>
How can I retrieve href content and value between the <a>
and </a>
tags?
Upvotes: 1
Views: 236
Reputation: 39374
I finally got the output by using
<a href=([^<]*) class=\"11-link-dkred-bold\"><b>([^<]*)</a>"
I have used \ before the double quotes.Just like printing the " in print statement.
Upvotes: 2
Reputation: 454960
Its recommended to use a HTML parser for such jobs.
If you want to use a regex you can try this:
<a href\s*=\s*"([^"]*)">([^<]*)</a>
First group will capture the href attribute value and second group will capture the text between the starting and closing tag.
Upvotes: 3