I have a big array of strings (characters a-z, A-Z and digits 0-9). I also have an input string, but few characters are missing (Example: /np/tSt/ing/), '/' represents missing character. I have to find every string from my array who can be formed from input string by replacing '/' with any character (Example: inputString1, AnpAtStAngA, 1np2tSt3ing4...). Is there any non brute-force solution for this problem?
Asked
Active
Viewed 495 times
1
-
This is called a wildcard. – Drag and Drop Jul 16 '18 at 08:30
-
Possible duplicate of [Matching strings with wildcard](https://stackoverflow.com/questions/30299671/matching-strings-with-wildcard) – Drag and Drop Jul 16 '18 at 08:30
1 Answers
4
You can use regular expressions for this. Something like .np.tSt.ing.
public static Regex regex = new Regex(".np.tSt.ing.", RegexOptions.CultureInvariant | RegexOptions.Compiled);
...
bool IsMatch = regex.IsMatch(InputText);

dlxeon
- 1,932
- 1
- 11
- 14