搜索缺少几个字符的字符串

时间:2018-07-16 08:21:36

标签: c# algorithm search

我有很多字符串(字符a-z,A-Z和数字0-9)。我也有一个输入字符串,但是缺少几个字符(例如:/ np / tSt / ing /),“ /”代表缺少的字符。我必须从数组中查找可以由输入字符串组成的每个字符串,方法是将“ /”替换为任何字符(例如:inputString1,AnpAtStAngA,1np2tSt3ing4 ...)。是否有解决此问题的非蛮力解决方案?

1 个答案:

答案 0 :(得分:4)

您可以为此使用正则表达式。像.np.tSt.ing.

public static Regex regex = new Regex(".np.tSt.ing.", RegexOptions.CultureInvariant | RegexOptions.Compiled);

...

bool IsMatch = regex.IsMatch(InputText);
相关问题