MatchAttribute(String) 建構函式

定義

使用指定的模式,初始化 MatchAttribute 類別的新執行個體。

C#
public MatchAttribute(string pattern);

參數

pattern
String

表示要符合模式的字串。

範例

C#
public class Example_Headers
{
    [MatchAttribute("TITLE>(.*?)<")]
    public string Title;

    [MatchAttribute("", Pattern="h1>(.*?)<", IgnoreCase=true)]
    public string H1;

    [MatchAttribute("H2>((([^<,]*),?)+)<", Group=3, Capture=4)]
    public string Element;

    [MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=0)]
    public string[] Elements1;

    [MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=1)]
    public string[] Elements2;

    [MatchAttribute("H3 ([^=]*)=([^>]*)", Group=1)]
    public string Attribute;

    [MatchAttribute("H3 ([^=]*)=([^>]*)", Group=2)]
    public string Value;
}

備註

使用此建構函式,使用指定的模式來建立和初始化 類別的新實例 MatchAttribute

下表顯示 實例 MatchAttribute 的初始屬性值。

屬性 初始值
模式 pattern 參數的值。

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1