Reputation: 1216
Given this string:
01/01/2000 Club Lets Rock Jonny
As you can see, I have 3 informations divided by spaces, and the second one Club Lets Rock
its one information with 2 blank spaces. Jony is the name of a person who send me this informations, I need to know, how may I get JUST the name of the person ? Is there a way to get it from the end of the string 'till it reaches the first blank space ?
I know there's a lot of others threads about substring
but none of them are like this. I also read the articles from some sites that explain substring
but couldn't find an appropriate for my case.
Upvotes: 0
Views: 136
Reputation: 35746
How about
var yourString = "01/01/2000 Club Lets Rock Jonny";
var everythingAfterTheLastSpace =
yourString.SubString(yourString.LastIndexOf(' ') + 1);
Upvotes: 3
Reputation: 3920
Split the string by using the space char as separator and get the Last item.
Something like:
string name = "01/01/2000 Club Lets Rock Jonny".Split(' ').Last();
Upvotes: 6