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 ?

3
  • 1
    have you read this ? stackoverflow.com/questions/1732348/… and sure you are not trying to parse html, and that this is a specific limited domain problem? Commented Mar 20, 2020 at 3:28
  • Does this answer your question? Elegant way parsing URL Commented Mar 20, 2020 at 3:38
  • that final quote isn't actually in the string, you know. You don't need to code for it. Commented Mar 20, 2020 at 4:53

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.