繁体   English   中英

在String.Replace上未处理ArgumentException

[英]ArgumentException was unhandled on String.Replace

我创建了两个带有“查找”和“替换为”组合的文本框。 然后,我遍历DataGridView中的单元格,并检查它是否包含“查找”框中的值。

在我尝试查找“(”并将其替换为“”空字符串之前,此方法一直运行良好

这是它在寻找“(”并在其中替换的字符串: The Hitch Hikers Guide to the Galaxy(S01xE06)

        string orig = (string)(dataGridView1.Rows[i].Cells["After"].Value);
        string newFilename = Regex.Replace(
orig, txtRenameFrom.Text, 
txtRenameTo.Text, 
RegexOptions.IgnoreCase);

然后,我收到此错误: 解析“(”-不够)。

您正在使用正则表达式替换,((是正则表达式中的特殊字符。请执行常规的String.Replace或正确地对正则表达式进行转义。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM