views:

87

answers:

2

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>

I want to retrieve href content and value between the and tag.Please help me out.Thanks.

+2  A: 

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.

codaddict
I want to retrieve the content of the tag which has class="11-link-dkred-bold".I have changed your expression as <a href=([^=]*)>([^<]*)</a> because yours showed compile time error for using s.
Warrior
Use: <a href ="([^"]*)" class="11-link-dkred-bold">([^<]*)</a>
codaddict
+2  A: 

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.

Warrior