As I understand your problem, you want to look nito a string. With any type of string, weather it is a declared or designed structure (or in C++ even a class) or simply just an array of characters [char *], you can look at individual elements.
I am not entirely sure this is the best or most efficient way, but if you were to have an array of characters like the following:
you could simply run through the array and look for characters with a
char Expression = "Xy xY";
you can even make an array of variables, which get expanded every time you find a character you have not found before.
for(i = 0;Expression[i] != '\0';i++)
// do your checking