string referrer = "?404;http://stage.hello.com:80/Applications/";
referrer = referrer.Substring(referrer.LastIndexOf("/") + 1);
By doing this I get referrer value ""
as answer.
I want my referrer value to be "Applications/"
How can I achieve this?
Any help will be greatly appreciated.
referrer = referrer.Substring(referrer.Substring(0, referrer.LastIndexOf("/")).LastIndexOf("/") + 1);
First variant:
referrer = Regex.Match(referrer, @"(?!/)[^/]*/[^/]*$").Value;
Second variant:
referrer = string.Join("/", referrer.Split('/').Reverse().Take(2).Reverse());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With