1

Possible Duplicate:
RegEx match open tags except XHTML self-contained tags

<a href="http://abc.com/abc.htm" style="color:#005F9A;">I need it</a>

How can i get "I need it" sentence? I want use regular expression...

Community
  • 1
  • 1
Özkan Selek
  • 21
  • 1
  • 4

1 Answers1

1

Here's the regex pattern that you can use to extract what you want:

(?<=\<a\shref=.*?\>).*?(?=\<\/a\>)
DelegateX
  • 719
  • 3
  • 8
  • 1
    FYI, `<`, `>` and `/` have no special meanings and do not need to be escaped. Also, lookarounds are an unnecessary complication; it's much simpler as well as more efficient to match the whole element "straight" and extract its content via a capturing group. – Alan Moore Sep 24 '12 at 03:44