RegexCompilationInfo クラス
アセンブリ: System (system.dll 内)


System.Text.RegularExpressions.RegexCompilationInfo


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


RegexCompilationInfo コンストラクタ
アセンブリ: System (system.dll 内)

Public Sub New ( _ pattern As String, _ options As RegexOptions, _ name As String, _ fullnamespace As String, _ ispublic As Boolean _ )
Dim pattern As String Dim options As RegexOptions Dim name As String Dim fullnamespace As String Dim ispublic As Boolean Dim instance As New RegexCompilationInfo(pattern, options, name, fullnamespace, ispublic)
public RegexCompilationInfo ( string pattern, RegexOptions options, string name, string fullnamespace, bool ispublic )
public: RegexCompilationInfo ( String^ pattern, RegexOptions options, String^ name, String^ fullnamespace, bool ispublic )
public RegexCompilationInfo ( String pattern, RegexOptions options, String name, String fullnamespace, boolean ispublic )
public function RegexCompilationInfo ( pattern : String, options : RegexOptions, name : String, fullnamespace : String, ispublic : boolean )

コンパイルされた正規表現を 3 つの手順で定義、作成、および使用するコード例を次に示します。
1 つ目の手順では、次のコード例をコンパイルします。コード例の RegexCompilationInfo コンストラクタによって、コンパイル対象の正規表現が定義されています。
' This code example demonstrates the RegexCompilationInfo constructor ' and the Regex.CompileToAssembly() method. ' compile: csc genFishRegex.cs Imports System Imports System.Reflection Imports System.Text.RegularExpressions Class GenFishRegEx Public Shared Sub Main() ' Pattern = Group matches one or more word characters, ' one or more white space characters, ' group matches the string "fish". Dim pat As String = "(\w+)\s+(fish)" ' Create the compilation information. ' Case-insensitive matching; type name = "FishRegex"; ' namespace = "MyApp"; type is public. Dim rci As New RegexCompilationInfo(pat, RegexOptions.IgnoreCase, _ "FishRegex", "MyApp", True) ' Setup to compile. Dim an As New AssemblyName() an.Name = "FishRegex" Dim rciList As RegexCompilationInfo() = New RegexCompilationInfo() { rci } ' Compile the regular expression. Regex.CompileToAssembly(rciList, an) End Sub 'Main End Class 'GenFishRegEx ' 'This code example produces the following results: ' '(Execute this code to generate the compiled regular 'expression assembly named FishRegex.dll. 'Use FishRegex.dll as a reference when compiling 'useFishRegex.cs.) '
// This code example demonstrates the RegexCompilationInfo constructor // and the Regex.CompileToAssembly() method. // compile: csc genFishRegex.cs namespace MyApp { using System; using System.Reflection; using System.Text.RegularExpressions; class GenFishRegEx { public static void Main() { // Pattern = Group matches one or more word characters, // one or more white space characters, // group matches the string "fish". string pat = @"(\w+)\s+(fish)"; // Create the compilation information. // Case-insensitive matching; type name = "FishRegex"; // namespace = "MyApp"; type is public. RegexCompilationInfo rci = new RegexCompilationInfo( pat, RegexOptions.IgnoreCase, "FishRegex", "MyApp", true); // Setup to compile. AssemblyName an = new AssemblyName(); an.Name = "FishRegex"; RegexCompilationInfo[] rciList = { rci }; // Compile the regular expression. Regex.CompileToAssembly(rciList, an); } } } /* This code example produces the following results: (Execute this code to generate the compiled regular expression assembly named FishRegex.dll. Use FishRegex.dll as a reference when compiling useFishRegex.cs.) */
2 つ目の手順では、手順 1 でコンパイルした実行可能ファイルを実行します。実行可能ファイルにより、FishRegex.dll アセンブリが作成されます。コンパイルされた正規表現型は FishRegex という名前になります。
3 つ目の手順では、FishRegex.dll への参照を使用して次のコード例をコンパイルし、生成された実行可能ファイルを実行します。この実行可能ファイルでは、FishRegex 型を使って、対象文字列内から一致するパターンを検索し、一致した文字列、グループ、キャプチャ グループ、およびインデックス位置を表示します。
' This code example demonstrates the RegexCompilationInfo constructor. ' Execute this code example after executing genFishRegex.exe. ' compile: vbc /r:FishRegex.dll useFishRegex.vb Imports System Imports System.Reflection Imports System.Text.RegularExpressions Class UseFishRegEx Public Shared Sub Main() ' Match against the following target string. Dim targetString As String = "One fish two fish red fish blue fish" Dim matchCount As Integer = 0 Dim f As New MyApp.FishRegex() ' Display the target string. Console.WriteLine(vbLf & "Input string = """ & targetString & """") ' Display each match, capture group, capture, and match position. Dim m As Match For Each m In f.Matches(targetString) matchCount = matchCount + 1 Console.WriteLine(vbLf & "Match(" & matchCount & ")") Dim i As Integer For i = 1 to 2 Dim g As Group = m.Groups(i) Console.WriteLine("Group(" & i & ") = """ & g.ToString() & """") Dim cc As CaptureCollection = g.Captures Dim j As Integer For j = 0 To cc.Count-1 Dim c As Capture = cc(j) System.Console.WriteLine("Capture(" & j & ") = """ & c.ToString() & _ """, Position = " & c.Index) Next j Next i Next m End Sub 'Main End Class 'UseFishRegEx ' 'This code example produces the following results: ' 'Input string = "One fish two fish red fish blue fish" ' 'Match(1) 'Group(1) = "One" 'Capture(0) = "One", Position = 0 'Group(2) = "fish" 'Capture(0) = "fish", Position = 4 ' 'Match(2) 'Group(1) = "two" 'Capture(0) = "two", Position = 9 'Group(2) = "fish" 'Capture(0) = "fish", Position = 13 ' 'Match(3) 'Group(1) = "red" 'Capture(0) = "red", Position = 18 'Group(2) = "fish" 'Capture(0) = "fish", Position = 22 ' 'Match(4) 'Group(1) = "blue" 'Capture(0) = "blue", Position = 27 'Group(2) = "fish" 'Capture(0) = "fish", Position = 32 '
// This code example demonstrates the RegexCompilationInfo constructor. // Execute this code example after executing genFishRegex.exe. // compile: csc /r:FishRegex.dll useFishRegex.cs namespace MyApp { using System; using System.Reflection; using System.Text.RegularExpressions; class UseFishRegEx { public static void Main() { // Match against the following target string. string targetString = "One fish two fish red fish blue fish"; int matchCount = 0; FishRegex f = new FishRegex(); // Display the target string. Console.WriteLine("\nInput string = \"" + targetString + "\""); // Display each match, capture group, capture, and match position. foreach (Match m in f.Matches(targetString)) { Console.WriteLine("\nMatch(" + (++matchCount) + ")"); for (int i = 1; i <= 2; i++) { Group g = m.Groups[i]; Console.WriteLine("Group(" + i + ") = \"" + g + "\""); CaptureCollection cc = g.Captures; for (int j = 0; j < cc.Count; j++) { Capture c = cc[j]; System.Console.WriteLine( "Capture(" + j + ") = \"" + c + "\", Position = " + c.Index); } } } } } } /* This code example produces the following results: Input string = "One fish two fish red fish blue fish" Match(1) Group(1) = "One" Capture(0) = "One", Position = 0 Group(2) = "fish" Capture(0) = "fish", Position = 4 Match(2) Group(1) = "two" Capture(0) = "two", Position = 9 Group(2) = "fish" Capture(0) = "fish", Position = 13 Match(3) Group(1) = "red" Capture(0) = "red", Position = 18 Group(2) = "fish" Capture(0) = "fish", Position = 22 Match(4) Group(1) = "blue" Capture(0) = "blue", Position = 27 Group(2) = "fish" Capture(0) = "fish", Position = 32 */

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


RegexCompilationInfo プロパティ

名前 | 説明 | |
---|---|---|
![]() | IsPublic | コンパイルされた正規表現をパブリックに参照できるかどうかを示す値を取得または設定します。 |
![]() | Name | コンパイルされた正規表現に使用する型の名前を取得または設定します。 |
![]() | Namespace | 新しい型を追加する名前空間を取得または設定します。 |
![]() | Options | 正規表現をコンパイルするときに使用するコンパイラ オプションを取得または設定します。 |
![]() | Pattern | コンパイルする正規表現を取得または設定します。 |

RegexCompilationInfo メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

RegexCompilationInfo メンバ
コンパイラが正規表現をコンパイルしてスタンドアロン アセンブリを作成するために使用する情報を提供します。
RegexCompilationInfo データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | IsPublic | コンパイルされた正規表現をパブリックに参照できるかどうかを示す値を取得または設定します。 |
![]() | Name | コンパイルされた正規表現に使用する型の名前を取得または設定します。 |
![]() | Namespace | 新しい型を追加する名前空間を取得または設定します。 |
![]() | Options | 正規表現をコンパイルするときに使用するコンパイラ オプションを取得または設定します。 |
![]() | Pattern | コンパイルする正規表現を取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からRegexCompilationInfoを検索する場合は、下記のリンクをクリックしてください。

- RegexCompilationInfoのページへのリンク