This is what I have so far:
string s = @"http://www.s3.locabal.com/whatever/bucket/folder/guid";
string p = @".*//(.*)";
var m = Regex.Match(s, p);
However, this returns "www.s3.locabal.com/whatever/bucket/folder/guid"
.
Use the Uri
class to parse URLs:
new Uri(s).Segments.Last()
Although Uri.Segments is probably the best way to do it, here are some alternatives:
string s = "http://www.s3.locabal.com/whatever/bucket/folder/guid";
// Uri
new Uri(s).Segments.Last();
// string
s.Substring(s.LastIndexOf("/") + 1);
// RegExp
Regex.Match(s, ".*/([^/]+*)$").Groups[1];
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