Using RegExp you can proceed in two ways, depending on your source input
Exemple 1
Assuming you have read your source and saved any single line in a vector or list :
string[] input = { "abc = tamaz feeo maa roo key gaera porla", "Xyz = gippaza eka jaguar ammaz te sanna." };
Regex mySplit = new Regex("(\\w+)\\s*=\\s*((\\w+).*)");
List<word> mylist = new List<word>();
foreach (string wordDef in input)
{
Match myMatch = mySplit.Match(wordDef);
word myWord;
myWord.Word = myMatch.Groups[1].Captures[0].Value;
myWord.Definition = myMatch.Groups[2].Captures[0].Value;
mylist.Add(myWord);
}
Exemple 2
Assuming you have read your source in a single variable (and any line is terminated with the line break character '\n') you can use the same regexp "(\w+)\s*=\s*((\w+).*)" but in this way
string inputs = "abc = tamaz feeo maa roo, key gaera porla\r\nXyz = gippaza eka jaguar; ammaz: te sanna.";
MatchCollection myMatches = mySplit.Matches(inputs);
foreach (Match singleMatch in myMatches)
{
word myWord;
myWord.Word = singleMatch.Groups[1].Captures[0].Value;
myWord.Definition = singleMatch.Groups[2].Captures[0].Value;
mylist.Add(myWord);
}
Lines that matches or does not match the regexp "(\w+)\s=\s*((\w+).)":
- "abc = tamaz feeo maa roo key gaera porla,qsdsdsqdqsd\n" --> Match!
- "Xyz= gippaza eka jaguar ammaz te sanna. sdq=sqds \n" --> Match! you can insert description that includes spaces too.
- "qsdqsd=\nsdsdsd\n" --> Match a multiline pair too!
- "sdqsd=\n" --> DO NOT Match! (lacking descr)
- "= sdq sqdqsd.\n" --> DO NOT Match! (lacking word)