System.RegularExpressions.TMatch

提供: RAD Studio API Documentation
移動先: 案内検索

Delphi

  TMatch = record
  private
    FGroup: TGroup;
    FGroups: TGroupCollection;
    FNotifier: IInterface;
    constructor Create(const ANotifier: IInterface; const AValue: string;
      AIndex, ALength: Integer; ASuccess: Boolean);
    function GetIndex: Integer;
    function GetGroups: TGroupCollection;
    function GetLength: Integer;
    function GetSuccess: Boolean;
    function GetValue: string;
  public
    function NextMatch: TMatch;
    function Result(const Pattern: string): string;
    property Groups: TGroupCollection read GetGroups;
    property Index: Integer read GetIndex;
    property Length: Integer read GetLength;
    property Success: Boolean read GetSuccess;
    property Value: string read GetValue;
  end;

C++

struct DECLSPEC_DRECORD TMatch
{
private:
    TGroup FGroup;
    TGroupCollection FGroups;
    System::_di_IInterface FNotifier;
protected:
    __fastcall TMatch(const System::_di_IInterface ANotifier, const System::UnicodeString AValue, int AIndex, int ALength, bool ASuccess);
private:
    int __fastcall GetIndex();
    TGroupCollection __fastcall GetGroups();
    int __fastcall GetLength();
    bool __fastcall GetSuccess();
    System::UnicodeString __fastcall GetValue();
public:
    TMatch __fastcall NextMatch();
    System::UnicodeString __fastcall Result(const System::UnicodeString Pattern);
    __property TGroupCollection Groups = {read=GetGroups};
    __property int Index = {read=GetIndex};
    __property int Length = {read=GetLength};
    __property bool Success = {read=GetSuccess};
    __property System::UnicodeString Value = {read=GetValue};
    TMatch() {}
};

プロパティ

種類 可視性 ソース ユニット
record
struct
public
System.RegularExpressions.pas
System.RegularExpressions.hpp
System.RegularExpressions System.RegularExpressions

説明

1 つの正規表現一致結果を含むレコード。

TMatch にはパブリックなコンストラクタがありません。 TMatch のインスタンスは、System.RegularExpressions.TRegEx.Match のようなメソッドの戻り値(ある文字列での最初のパターン一致を表す)として作成されます。 TMatch は、NextMatch の戻り値型にもなっています。 System.RegularExpressions.TRegEx.Matches は、見つかったすべての一致結果を含む TMatchCollection を返します。

パターン一致に成功した場合、Value プロパティには、一致した部分文字列が含まれます。Index プロパティには、入力文字列内で一致した部分文字列の位置(0 を始点とする)が含まれます。Length プロパティには、入力文字列内で一致した部分文字列の長さが含まれます。

1 つの一致結果が複数のキャプチャ グループに関与している場合があるため、TMatch は、TGroupCollection 型の Groups プロパティを持っています。

関連項目