2014-05-23 23 views
0

我想查找和轉換在某些文件中具有爭議的語句。用於替換語句中的論題的正則表達式

搜索語句是這樣的:

db.AddInParameter(command, "@id", DbType.Int32, entity.Id); 

結果說法是這樣的:

command.Parameters.AddWithValue("@id", entity.Id); 

我使用記事本+ +和努力正則表達式來創建搜索字符串。我試圖

  1. db.AddInParameter*\"@+[a-z]\"*
  2. db.AddInParameter*"@+[a-z]"*

但不能創建正確的搜索字符串。

請建議正確的搜索和替換字符串。

+0

也許讀了上正則表達式的語法,尤其是'*'。 – Biffen

+0

看起來他知道'*',但他不知道'。' – Barmar

回答

1

只需要改變我的加入開始和結束括號

所以,我的替換字符串是:

\1.Parameters.AddWithValue\(\2, \3\); 
0

搜索:db.AddInParameter\((.*?), ("@[a-z]+"), .*?, (.*)\);

替換:\1.Parameters.AddWithValue(\2, \3);

+0

謝謝。這對我有效。 – Suraj