求正则表达式 VS2005的正则表达式替换
下面是WebSvc代理类的代码
[System.Web.Services.Protocols.SoapRpcMethodAttribute( "WSFacade ", RequestNamespace= "http://www.sb3.services1.extend.com/jboss-net/services/WSFacade ", ResponseNamespace= "http://www.sb3.services1.extend.com/jboss-net/services/WSFacade ")]
[return: System.Xml.Serialization.SoapElementAttribute( "createCustomerReturn ")]
public ProfileTO createCustomer(string accountAltcode, ProfileTO profile) {
object[] results = this.Invoke( "createCustomer ", new object[] {
accountAltcode,
profile});
return ((ProfileTO)(results[0]));
}
要求替换为:
[System.Web.Services.Protocols.SoapRpcMethodAttribute( "WSFacade ", RequestNamespace= "http://www.sb3.services1.extend.com/jboss-net/services/WSFacade ", ResponseNamespace= "http://www.sb3.services1.extend.com/jboss-net/services/WSFacade ")]
[return: System.Xml.Serialization.SoapElementAttribute( "createCustomerReturn ")]
[TraceExtensionAttribute(LogDirectory = "ExtendMedia ", EventType = "createCustomer ")]
public ProfileTO createCustomer(string accountAltcode, ProfileTO profile) {
object[] results = this.Invoke( "createCustomer ", new object[] {
accountAltcode,
profile});
return ((ProfileTO)(results[0]));
}
我现在使用的正则式为:
匹配:public {[^\s]+} {[^\(]+}\(
替换为:[TraceExtensionAttribute(LogDirectory= "ExtendMedia ",EventType= "\2 ")]\n\t\tpublic \1 \2\ (
这个替换能够工作,但是它替换了很多不该替换的函数,
我想再加一个条件,函数前面有 [System.Web.Services.Protocols.SoapRpcMethodAttribute 属性的函数才替换,但是一直改不好....
------解决方案--------------------这个表达式是用VS2005的查找替换工具替换的
-----------------------------------------
才看明白,我说你所用的替换表达式怎么不符合正则规则呢
我的解决办法是这样的,其中method 为变化的函数名称