我有一个字符串:“https://mhnkp2.com/src/vid/pra/Tentang_Mata-Cerita_Boneka-Prasekolah.mp4”
我只想得到“Tentang_Mata-Cerita_Boneka-Prasekolah”
我尝试使用代码:
string path = "https:\/\/mhnkp2.com\/src\/vid\/pra\/Tentang_Mata-Cerita_Boneka-Prasekolah.mp4"
int start = path.IndexOf("/") + 5;
int end = path.IndexOf(".", start);
string result = path.Substring(start, end - start);
但结果只有“kp”。如何处理?
最佳答案
你可以使用
System.IO.Path.GetFileNameWithoutExtension("https://mhnkp2.com/src/vid/pra/Tentang_Mata-Cerita_Boneka-Prasekolah.mp4")
关于c# - 获取特定字符之间的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57372507/