我正在尝试使用 C# 查找并删除字符串中的特定模式。
模式是一个星号,后跟任意数量的数字,后跟 .txt
示例字符串:
鉴于这些示例,预期的结果将是:
如何做到这一点?
最佳答案
string pattern = @"\*\d*\.txt";
Regex rgx = new Regex(pattern)
input = rgx.Replace(input, "");
关于c# - 使用 C# 在字符串中查找特定模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5173049/