[Solved] Simple regex – parse Firstname Lastname, sex (male,female), age or birth year


You only want “name, sex, age(or YearOfBirth)”
You still can use Regex for it, or String.Split:

Split solution:

string line = "Max Smith m 20";
string[] words = line.Split(" ");

int nr = items[words.Length - 1]; 
//use number to determine age or year
string gender = items[words.Length - 2];
//string name = combine the leftover elements from the array

For the regex solution you have to take into account matching from right to left due names with extra spaces: Max D. Smith jr. m 1978 (Example by Filburt)

2

solved Simple regex – parse Firstname Lastname, sex (male,female), age or birth year