Split string by last separator

后端 未结 3 1490
名媛妹妹
名媛妹妹 2021-02-18 13:39

What I have is a giant text file that contains a bunch of strings that are split by \\. The problem for me is there can be 5 \\ or 4 \\ o

相关标签:
3条回答
  • 2021-02-18 13:52
    string last = inputString.Substring(inputString.LastIndexOf('\\') + 1);
    
    0 讨论(0)
  • 2021-02-18 14:00
    string myString = inputString.Split('\\').Last();
    
    0 讨论(0)
  • Almost forgot this one (although it's a bit cheeky):

    string result = Path.GetFilename(input);

    0 讨论(0)
提交回复
热议问题