【问题标题】:Search for string with few missing characters搜索缺少字符少的字符串
【发布时间】:2018-07-16 08:21:36
【问题描述】:

我有一大堆字符串(字符 a-z、A-Z 和数字 0-9)。我也有一个输入字符串,但缺少几个字符(例如:/np/tSt/ing/),'/' 表示缺少字符。我必须从我的数组中找到可以通过用任何字符替换“/”来从输入字符串形成的每个字符串(例如:inputString1、AnpAtStAngA、1np2tSt3ing4 ...)。这个问题有没有非暴力破解的方法?

【问题讨论】:

标签: c# algorithm search


【解决方案1】:

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

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

...

bool IsMatch = regex.IsMatch(InputText);

【讨论】:

  • 完美运行!
猜你喜欢
  • 2021-10-16
  • 2015-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-15
相关资源
最近更新 更多