1

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Warrior
  • 39,156
  • 44
  • 139
  • 214

2 Answers2

3

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
  • 445,704
  • 82
  • 492
  • 529
2

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
  • 39,156
  • 44
  • 139
  • 214