如何通过RegEx从网址中获取部分内容

STO*_*ORM -1 c# regex url

我有两个网址:

http://sp2013/sites/1234
Run Code Online (Sandbox Code Playgroud)

http://sp2013/pwa/projectsites/projectdetails.aspx?projuid=1234-123-123-123456-123456
Run Code Online (Sandbox Code Playgroud)

我想从第一个网址获取最后一部分(总是一个数字)

1234
Run Code Online (Sandbox Code Playgroud)

从第二个网址也是最后一部分(guid)

1234-123-123-123456-123456
Run Code Online (Sandbox Code Playgroud)

我如何通过RegEx实现这一点,或者在C#中使用字符串操作?

小智 5

string s = "http://sp2013/sites/1234";
var firstURLlastPart = new Uri(s).Segments.Last();

string s = "http://sp2013/pwa/projectsites/projectdetails.aspx?projuid=1234-123-123-123456-123456";
var secondURLlastPart = s.Split('=').Last();
Run Code Online (Sandbox Code Playgroud)