📄 3.12.txt
字号:
Listing 3.12 Using the CompileToAssembly Regex Method to Save Regular
Expressions in a New Assembly for Later Reuse
using System;
using System.Text.RegularExpressions;
using System.Reflection;
namespace _12_RegExpReplace
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
CompileRegex(@”(\d{4})-(\d{4})-(\d{4})-(\d{4})”, @”regexlib” );
}
static void CompileRegex( string exp, string assemblyName )
{
RegexCompilationInfo compInfo =
new RegexCompilationInfo( exp, 0, “CreditCardExp”, “”, true );
AssemblyName assembly = new AssemblyName();
assembly.Name = assemblyName;
RegexCompilationInfo[] rciArray = { compInfo };
Regex.CompileToAssembly( rciArray, assembly );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -