Regex 用于替换语句中参数的正则表达式
我想在一些文件中查找并转换包含参数的语句 搜索语句如下所示:Regex 用于替换语句中参数的正则表达式,regex,search,replace,Regex,Search,Replace,我想在一些文件中查找并转换包含参数的语句 搜索语句如下所示: db.AddInParameter(command, "@id", DbType.Int32, entity.Id); 结果陈述如下: command.Parameters.AddWithValue("@id", entity.Id); 我正在使用Notepad++并尝试使用正则表达式来创建搜索字符串。我试过了 db.AddInParameter*\“@+[a-z]\”* db.AddInParameter*“@+[a-z]”*
db.AddInParameter(command, "@id", DbType.Int32, entity.Id);
结果陈述如下:
command.Parameters.AddWithValue("@id", entity.Id);
我正在使用Notepad++并尝试使用正则表达式来创建搜索字符串。我试过了
db.AddInParameter*\“@+[a-z]\”*
db.AddInParameter*“@+[a-z]”*
请建议正确的搜索和替换字符串。搜索:
db.AddInParameter\((.*),(“@[a-z]+”),.?,(.*)代码>
替换:\1.Parameters.AddWithValue(\2\3)代码>我唯一需要的更改是添加开始和结束括号
因此,我的替换字符串是:
\1.Parameters.AddWithValue\(\2, \3\);
也许读过正则表达式语法,尤其是*
。看起来他知道*
,但他不知道