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