我希望在AssemblyInfo文件中匹配AssemblyKeyName中的内容。下面是我的AssemblyInfo文件:using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;// 有关程序集的常规信息通过下列属性集
// 控制。更改这些属性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("WpfBrowserGrpApplication.exe")]
[assembly: AssemblyDescription("WpfBrowserGrpApplication.exe")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ControlEase Automation Software Co., Ltd.")]
[assembly: AssemblyProduct("INSPEC")]
[assembly: AssemblyCopyright("Copyright (C) 2003 ControlEase Automation Software. All rights reserved.")]
[assembly: AssemblyTrade("")]
[assembly: AssemblyCulture("")]// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 属性设置为 true。
[assembly: ComVisible(false)]//若要开始生成可本地化的应用程序,请在 
//<PropertyGroup> 中的 .csproj 文件中
//设置 <UICulture>CultureYouAreCodingWith</UICulture>。例如,如果您在源文件中
//使用的是美国英语,请将 <UICulture> 设置为 en-US。然后取消
//对以下 NeutralResourceLanguage 属性的注释。更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
    ResourceDictionaryLocation.None, //主题特定资源词典所处位置
    //(在页面或应用程序资源词典中 
    // 未找到某个资源的情况下使用)
    ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
    //(在页面、应用程序或任何主题特定资源词典中
    // 未找到某个资源的情况下使用)
)]
// 程序集的版本信息由下面四个值组成:
//
//      主版本
//      次版本 
//      内部版本号
//      修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.*")]
[assembly: AssemblyFileVersion("1.0.3557.1415")]
#pragma warning disable 1699
[assembly: AssemblyKeyName(@"JIUSIYI_yangfeiyang_InGrpBrowserContainer")]
#pragma warning restore 1699红色部分是我想要的,怎么写正则表达式?

解决方案 »

  1.   


    (?<=AssemblyKeyName\(@")[\s|\S]*?(?=")
      

  2.   

    @"AssemblyKeyName(@""(?<Name>[^""]*)"".*)
      

  3.   


    Regex regex = new Regex("(?<=AssemblyKeyName\\(@\")[\\s|\\S]*?(?=\")", RegexOptions.Multiline | RegexOptions.Compiled);
                regex.Replace("原字符串", "替换字符串");
      

  4.   

                string str = "[assembly: AssemblyKeyName(@\"JIUSIYI_yangfeiyang_InGrpBrowserContainer\")] ";
                Regex re = new Regex(@"\[assembly: AssemblyKeyName\(\@""([^""]+)""");
                Match m = re.Match(str);
                if (m.Success)
                {
                    str = str.Replace(m.Groups[1].ToString(),"aaaaaaaaaa");
                }
                Console.WriteLine(str);
      

  5.   

    string str = "[assembly: AssemblyKeyName(@\"JIUSIYI_yangfeiyang_InGrpBrowserContainer\")] ";
    str = Regex.Replace(str, @"(?<=\[assembly: AssemblyKeyName\(\@"")[^""]+(?=""\)\])", "aaaaaaaa");
    Console.WriteLine(str);
      

  6.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string str = @"[assembly: AssemblyVersion(""1.0.0.*"")] 
    [assembly: AssemblyFileVersion(""1.0.3557.1415"")] 
    #pragma warning disable 1699 
    [assembly: AssemblyKeyName(@""JIUSIYI_yangfeiyang_InGrpBrowserContainer"")] 
    #pragma warning restore 1699 
    ";
                Regex re = new Regex(@"\[assembly:\s*AssemblyKeyName\(\@""(?<name>[^""]*)""\)\]");
                if(re.Match(str).Success)
    Console.WriteLine(str.Replace(re.Match(str).Groups["name"].Value,"New New"));    
     
            }
        }
    }
      

  7.   

    环视效率不一定高的,这个简单
    string.Replace(@"AssemblyKeyName\(@"[^"]*"\)", "")