I have two strings: the first's value is "catdog" and the second's is "got".
I'm trying to find a regex that tells me if the letters for "got" are in "catdog". I'm particularly looking to avoid the case where there are duplicate letters. For example, I know "got" is a match, however "gott" is not a match because there are not two "t" in "catdog".
EDIT:
Based on Adam's response below this is the C# code I got to work in my solution. Thanks to all those that responded.
Note: I had to convert the char to int and subtract 97 to get the appropriate index for the array. In my case the letters are always lower case.
private bool CompareParts(string a, string b)
{
int[] count1 = new int[26];
int[] count2 = new int[26];
foreach (var item in a.ToCharArray())
count1[(int)item - 97]++;
foreach (var item in b.ToCharArray())
count2[(int)item - 97]++;
for (int i = 0; i < count1.Length; i++)
if(count2[i] > count1[i])
return false;
return true;
}