如何使用正则表达式删除ASP .NET AJAX Toolkit中的选项卡属性

时间:2009-09-12 05:45:38

标签: asp.net regex visual-studio-2008 asp.net-ajax tabcontrol

我试图删除AJAX Control工具包生成的以下标记。 方案是我们的GUI团队使用AJAX控件工具包来制作GUI,但我需要使用MultiView将它们移动到普通的ASP .NET视图标记。

我想删除所有__designer:attributes

这是代码

<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中使用正则表达式find replace:

查找

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

替换为空格

任何正则表达专家都可以帮忙吗?

3 个答案:

答案 0 :(得分:4)

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

使用此正则表达式

&LT; __设计师的azazaz =:Q

答案 1 :(得分: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);
        }
    }
}

答案 2 :(得分:0)

来自“查找选项”的

使用通配符搜索:

  

__ designer:wfdid =“*”

找到所有这些并替换为空。