Regex.CompileToAssembly : Regex « System.Text.RegularExpressions « C# / C Sharp by API






Regex.CompileToAssembly

  
using System;
using System.Reflection;
using System.Text.RegularExpressions;

class MainClass {
    public static void Main() {
        RegexCompilationInfo[] regexInfo = new RegexCompilationInfo[2];
        regexInfo[0] = new RegexCompilationInfo(@"^\d{4}$", RegexOptions.Compiled, "PinRegex", "", true);
        regexInfo[1] = new RegexCompilationInfo(@"^\d{4}-?\d{4}-?\d{4}-?\d{4}$", RegexOptions.Compiled, "CreditCardRegex", "", true);
        AssemblyName assembly = new AssemblyName();
        assembly.Name = "MyRegEx";

        Regex.CompileToAssembly(regexInfo, assembly);
    }
}

   
    
  








Related examples in the same category

1.new Regex(String pattern)
2.Regex.IsMatch
3.Regex.Match(String value,String pattern).Success
4.Regex.Replace
5.Regex.Match
6.Regex.Split