如何在字符串的特定子字符串后获取字符串?

RJ.*_*RJ. -1 .net c# string

可能重复:
如何从大量丑陋的字符串中提取特定字符串的PART?

串:

https://company.zendesk.com/api/v2/tickets/33126.json
Run Code Online (Sandbox Code Playgroud)

我需要33126号.

提取这个数字的最佳方法是什么?

Tim*_*ter 6

由于这是路径/网址,请使用 Path.GetFileNameWithoutExtension:

string name = Path.GetFileNameWithoutExtension(path);
Run Code Online (Sandbox Code Playgroud)

我更喜欢Path,但如果你想使用这个Uri类,你也可以使用它:

Uri uri = new Uri("https://company.zendesk.com/api/v2/tickets/33126.json");
string lastSegment = uri.Segments.Last();
string name = lastSegment.Substring(0, lastSegment.IndexOf('.'));
Run Code Online (Sandbox Code Playgroud)