0

I 'm having a link like this

href="abc.com/Details/gotoTicket?ticketID=EO8"

I want get an ID beetwen gotoTicket?ticketID= and ".

The result of link above I want is EO8

How can I do that with Regex ?

Alex
  • 727
  • 1
  • 13
  • 32
  • 1
    have you read this ? https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 and sure you are not trying to parse html, and that this is a specific limited domain problem? – TheGeneral Mar 20 '20 at 03:28
  • Does this answer your question? [Elegant way parsing URL](https://stackoverflow.com/questions/15713542/elegant-way-parsing-url) – ggorlen Mar 20 '20 at 03:38
  • that final quote isn't actually in the string, you know. You don't need to code for it. – John Lord Mar 20 '20 at 04:53

1 Answers1

1

You don't need regex for that. You can use the HttpUtility to get your query string, e.g.

var href = new Uri("http://example.org/Details/gotoTicket?ticketID=EO8");
string ticketId = HttpUtility.ParseQueryString(href.Query).Get("ticketID");

Just make sure that your href (URL) starts with a scheme.

Kenan Güler
  • 1,868
  • 5
  • 16