-1

I'm trying to get the text inside an href link, in particular I've this:

<a href="/matches/2015/02/07/italy/serie-a/juventus-fc/ac-milan/1836527/" class="form-icon form-win " title="Juventus - Milan 3 - 1">W</a>

So I made this regex:

.giornata_1_casa_flag = Regex.Match(Casa_Rgx(0).Value, "/<a [^>]*href=""?([^"">]+)""?>/").Groups(2).ToString

the pattern, however, don't get any value. I'm waiting a result like: W. This character allow me to execute many control.

Anton Ego
  • 27
  • 1
  • 10

2 Answers2

0

I would try to search for any text between > and </a>, probably not the best approach, but it depends on the html you have.

Here is the pattern: (?<=>)[a-z\s]*(?=<\/a>)

(?<=>) - positive lookbehind, means that before text should be > sign

(?=<\/a>) - positive lookahead, means that text should be followed by </a>

Demo: https://regex101.com/r/iC9uR4/2

streetturtle
  • 5,472
  • 2
  • 25
  • 43
0

using jQuery

var link = "<a href=''>Text link</a>"
var textLink = $(link).text();