I am trying to figure out how to write a C# function that returns true if there is a "match" between two strings. The numbers in the string will always be sorted in asc order.
string1: 1,3
string2: 1,2,3
The function should return true if all the numbers in string1 are found in string2. In the example above the return value should be true.
string1: 1,2,4
string2: 1,2,3
In the example above the return false should be false because not all numbers in string1 are found in string2.
The base case of string1 being an empty string should always return true no matter what string2 contains.
I am thinking of splitting both strings into arrays and trying to do a match and would also be interested in a regex option. Open to any ideas you may have.
I can handle writing the function so really just looking for ideas on the "best" way to accomplish this. And by "best" I mean the option that you think performances the fastest (and yes, I will test on my hardware for performance before moving into production).
The strings at most would have 10 numbers in them, if that helps. We will never see a string with hundreds of numbers.