Guest User

Untitled

a guest
Jan 4th, 2013
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. private string title(string pth) //I'm passing a path
  2. {
  3. pth = System.IO.Path.GetFileNameWithoutExtension(pth); // I need an exact filename with no extension
  4. return pth.Substring(pth.IndexOf('-')+1, pth.Length).Trim(); // trying to return everything after '-'
  5. }
  6.  
  7. return pth.Substring(pth.IndexOf('-')+1, pth.Length).Trim();
  8.  
  9. return pth.Substring(pth.IndexOf('-')+1).Trim();
  10.  
  11. private string title(string pth) //I'm passing a path
  12. {
  13. pth = System.IO.Path.GetFileNameWithoutExtension(pth); // I need an exact filename with no extension
  14. string retStr = string.Empty;
  15. if(pth.IndexOf('-')<pth.Length-1)
  16. {
  17. retStr = pth.Substring(pth.IndexOf('-')+1).Trim(); // trying to return everything after '-'
  18. }
  19. return retStr;
  20. }
  21.  
  22. private static string title(string pth)
  23. {
  24. pth = System.IO.Path.GetFileNameWithoutExtension(pth); // I need an exact filename with no extension
  25. Match m = Regex.Match(pth, @".*-(?<suffix>.*)$");
  26.  
  27. Group suffix = m.Groups["suffix"];
  28. return suffix.Success ? suffix.Value : pth;
  29. }
  30.  
  31. int index = pth.IndexOf('-');
  32. return pth.Substring(index + 1, pth.Length - index - 1);
  33.  
  34. if(pth.IndexOf('-') != -1)
  35. {
  36. //Substring code
  37. }
  38.  
  39. pth.Substring(pth.IndexOf('-')+1, pth.Length)
  40.  
  41. pth.Substring(pth.IndexOf('-')+1)
  42.  
  43. private string title(string pth) //I'm passing a path
  44. {
  45. pth = System.IO.Path.GetFileNameWithoutExtension(pth);
  46. return pth.Substring(pth.IndexOf('-')+1, pth.Length - pth.IndexOf('-') - 1).Trim();
  47. }
  48.  
  49. private string title(string pth) //I'm passing a path
  50. {
  51. pth = System.IO.Path.GetFileNameWithoutExtension(pth);
  52. var indexOfDash = pth.IndexOf('-') + 1; // Add this line
  53. return pth.Substring(indexOfDash, pth.Length - indexOfDash).Trim();
  54. }
Add Comment
Please, Sign In to add comment