简体   繁体   中英

ArgumentException was unhandled on String.Replace

I created two textboxes with "find" and "replace with" sort of combination. I then loop through cells in a DataGridView and check to see if it contains the value in the "find" box.

This has been working fine until I tried to find and replace "(" with "" empty string

This is the string it is looking for the "(" to find and replace in: 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);

Then I receive this error: parsing "(" - Not enough )'s.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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