3 Replies - 419 Views - Last Post: 03 March 2012 - 12:35 PM Rate Topic: -----

#1 riccardolore  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-March 12

Can't find correct Pattern for Regex

Posted 03 March 2012 - 09:48 AM

Hi guys, i hope you'll be able to help me..
I need your help to find the right pattern to extract a string that i need.. The problem is that i have to extract all there is between this caracters:
<a href="/url?q=(text to extract whatever it is)&amp


I tried this pattern, but it's not working for me! :
/(?<=url\?q=).*?(?=&amp)/


i'm programming in Vb.net, this is the code, but i think that the problem is that the pattern is wrong:

Dim matches As MatchCollection
        matches = regex.Matches(TextBox1.Text)
        For Each Match As Match In matches
            listbox1.items.add(Match.Value)
        Next



Is This A Good Question/Topic? 0
  • +

Replies To: Can't find correct Pattern for Regex

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9286
  • View blog
  • Posts: 34,807
  • Joined: 12-June 08

Re: Can't find correct Pattern for Regex

Posted 03 March 2012 - 10:03 AM

I would probably start more simply with a

.*q=

Was This Post Helpful? 0
  • +
  • -

#3 riccardolore  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-March 12

Re: Can't find correct Pattern for Regex

Posted 03 March 2012 - 10:17 AM

what do you mean? o.O where i have to use it? how? i don't understand
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2264
  • View blog
  • Posts: 9,470
  • Joined: 29-May 08

Re: Can't find correct Pattern for Regex

Posted 03 March 2012 - 12:35 PM

There's already a component that does this, it's called HTMLDocument, which has method to get all the hyperlinks in the documents.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1