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\"
string[] array = new string[]{"big", "bad", "dog"};
for(ulong mask = 0; mask < (1ul << array.Length); mask++)
{
string permutation = "";
for(int i = 0; i < array.Length; i++)
{
if((mask & (1ul << (array.Length - 1 - i))) != 0)
{
permutation += array[i] + " ";
}
}
Console.WriteLine(permutation);
}
EDIT: No, it can not be done using only a single regular expression.
EDIT: Per Eric Lippert, change masks to ulong (UInt64).