Hi,
I have this string: " Mimi loves Toto and Tata hate Mimi so Toto killed Tata"
I want to write a code that print only the words that begin with capital letters, avoiding repetition
the Output should be like
Mimi
Toto
Tata
I tried to do so but I'm sure its wrong even though no errors are showing.
The code i wrote :
static void Main(string[] args)
{
string s = "Memi ate Toto and she killed Tata Memi also hate Biso";
Console.WriteLine((spliter(s)));
}
public static string spliter(string s)
{
string x = s;
Regex exp = new Regex(@"[A-Z]");
MatchCollection M = exp.Matches(s);
foreach (Match t in M)
{
while (x != null)
{
x = t.Value;
}
}
return x;
}
}
}
Idea:
What if i split the string into an array, then apply a regex to check them word by word and then print the results ? I don't know - can any one help me in making this code work?