Results 1 to 3 of 3

Thread: How to get text inside href?

  1. #1

    Thread Starter
    Addicted Member JackIlPazzo's Avatar
    Join Date
    Oct 2014
    Posts
    183

    How to get text inside href?

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

    Code:
    <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

    Code:
    .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.

  2. #2
    Fanatic Member Toph's Avatar
    Join Date
    Oct 2014
    Posts
    655

    Re: How to get text inside href?

    <a href="/(.*)/"

  3. #3
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,390

    Re: How to get text inside href?

    Tophs pattern will fail as it's greedy. The pattern should be lazy while matching any thing thats not a ".

    vb Code:
    1. MessageBox.Show(New Regex("<a href=""([^""]+)(.+?)").Match(source).Groups(1).Value)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width