2009-09-12 29 views
0

我试图删除由AJAX控件工具包生成以下标记删除ASP .NET AJAX工具包一个标签属性。 这个场景是我们的GUI团队使用AJAX控件工具包来制作GUI,但我需要使用MultiView将它们移动到普通的ASP .NET视图标签。如何使用正则表达式

我想删除所有__designer:属性

下面是代码

<asp:TextBox ID="a" runat="server" __designer:wfdid="w540" /> 
<asp:DropdownList ID="a" runat="server" __designer:wfdid="w541" /> 
..... 
<asp:DropdownList ID="a" runat="server" __designer:wfdid="w786" /> 

我试图用正则表达式发现使用Visual Studio中的替换:

查找:

:__designer\:wfdid="w{([0-9]+)}" 

更换空的空间

任何正则表达式专家都可以提供帮助吗?

回答

2
/* 
* Created by SharpDevelop. 
* User: box 
* Date: 2009-9-13 
* Time: 8:13 
* 
* To change this template use Tools | Options | Coding | Edit Standard Headers. 
*/ 
using System; 
using System.Text.RegularExpressions; 

namespace t1 
{ 
    class Sample 
    { 
     public static void Main() 
     { 
      // Create a regular expression that matches a series of one 
      // or more white spaces. 
      string pattern = @"__designer:wfdid=""w\d+"""; 
      Regex rgx = new Regex(pattern); 

      // Declare a string consisting of text and white spaces. 
      string aspCode = @"<asp:TextBox ID=""a"" runat=""server"" __designer:wfdid=""w540"" />"; 

      // Replace runs of white space in the input string with a 
      // comma and a blank. 
      string outputStr = rgx.Replace(aspCode, ", "); 

      // Display the resulting string. 
      Console.WriteLine("Pattern:  \"{0}\"", pattern); 
      Console.WriteLine("Input string: \"{0}\"", aspCode); 
      Console.WriteLine("Output string: \"{0}\"", outputStr); 
     } 
    } 
} 
+1

是不需要的程序,原来的海报(OP)是使用了VS查找命令以删除这些属性。 @“__ designer:wfdid =”“w \ d +”“”会做。一个很好的方法是在属性后面删除额外的空间,以避免有两个空间并增加整洁度。 – Kobi

+0

我明白了。但我只安装了Visual Studio 6.0。 ,P – boxoft

4

如果你想摆脱__designer的:的azazaz = “22”

使用这个表达式

< __designer:的azazaz =:Q

0

从 '查找选项' 使用通配符搜索:

__designer:wfdid =“*”

找到它们并用空来替换。