I have a string such as \"big bad dog\", how can I get an string[] array which includes all the possible word/phrase combinations?
So, I would like to return \"big\"
What about splitting the string into array of separate words
string str = "big fat dog";
string[] words = str.Split(new Char[] { ' ', ',', '.', ':', '\t' });
and then you can use this to make word combinations
string[] words = new string[]{"big", "bad", "dog"}; for(int mask = 0; mask < 1 << (words.Length); mask++) { string permutation = ""; for(int i = 0; i < words.Length; i++) { if((mask & (1 << (words.Length - 1 - i))) != 0) { permutation += words[i] + " "; } } Console.WriteLine(permutation); }
I think regular expresion has no use here.