简体   繁体   中英

Get string between 2 known string by Regex

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 ?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM