使用通配符/正则表达式查找&在Visual Studio中替换

时间:2013-08-12 20:41:02

标签: regex visual-studio-2010

我需要用receiveTimeOut替换receiveTimeOut="59:59:59"属性的不同值 在Visual Studio中可以使用通配符搜索来完成此任务吗?

<endpoint receiveTimeOut="10:10:20" someOtherProperty="x1" yetAnotherProperty="y1" />
<endpoint receiveTimeOut="10:50:20" someOtherProperty="x2" yetAnotherProperty="y2" />
...
<endpoint receiveTimeOut="30:50:20" someOtherProperty="x3" yetAnotherProperty="y3" />

我试过在Find&amp;中使用通配符选项替换对话框receiveTimeOut="*",但这会选择完整的行receiveTimeOut="10:10:20" someOtherProperty="x1" yetAnotherProperty="y1" />

正如您可能已经猜到的那样,我正在编辑WCF服务web.config并且必须手动执行此任务&amp;反复。

3 个答案:

答案 0 :(得分:8)

使用正则表达式选项...

查找:<endpoint receiveTimeOut="[^"]+"

则...

替换:<endpoint receiveTimeOut="59:59:59"

[^"]+部分使用负字符类来匹配除双引号之外的任何字符。 +会匹配一次或多次。

答案 1 :(得分:1)

事实证明,这对于正则表达式来说实际上非常简单。 只需使用。*作为通配符并检查使用正则表达式。 例如,我有一些网格,我想找到属性为Visible =&#34; False&#34;的列。 所以字符串可能是:telerik:GridBoundColumn name =&#34; name&#34;可见=#&34;假&#34; 我的搜索字符串是:&#34; GridBoundColumn。* Visible =&#34; False&#34;&#34; 完成。

答案 2 :(得分:0)

艾哈迈德是要走的路。但作为一种天真的,有点不同的选择,人们可以搜索:

receiveTimeOut="[0-9]*\:[0-9]*\:[0-9]*"

这要求receiveTimeOut值的双引号之间的数据有两个冒号(它们被转义),其中包含任意数量的数字。

相关问题