我正在寻找可以用空字符串替换[[Something:SomethingElse]]
的任何实例的正则表达式。
答案 0 :(得分:0)
试试这个正则表达式:\[\[.*?:.*?\]\]
string str = @"some string before pattern [[Something:SomethingElse]] between
pattern [[doesnt matter:at all]] after pattern";
string result = Regex.Replace(str, @"\[\[.*?:.*?\]\]", "");
Outout:
some string before pattern between pattern after pattern
答案 1 :(得分:0)
使用Regex.Replace和LookArounds:
value = Regex.Replace(value, @"(?=\[\[)(.*?:.*?)(?<=\]\])", string.Empty);
测试用例:
string value = "89as89d98as98d[[lksdlkfajks03:34]],[[939203902:ksadfjlkaklsdf]]9390290390ks";
输出:
value = "89as89d98as98d,9390290390ks"