System.RegularExpressions.TGroup
Delphi
TGroup = record
private
FIndex: Integer;
FLength: Integer;
FSuccess: Boolean;
FValue: string;
constructor Create(const AValue: string; AIndex, ALength: Integer; ASuccess: Boolean);
function GetValue: string;
public
property Index: Integer read FIndex;
property Length: Integer read FLength;
property Success: Boolean read FSuccess;
property Value: string read GetValue;
end;
C++
struct DECLSPEC_DRECORD TGroup
{
private:
int FIndex;
int FLength;
bool FSuccess;
System::UnicodeString FValue;
protected:
__fastcall TGroup(const System::UnicodeString AValue, int AIndex, int ALength, bool ASuccess);
private:
System::UnicodeString __fastcall GetValue();
public:
__property int Index = {read=FIndex};
__property int Length = {read=FLength};
__property bool Success = {read=FSuccess};
__property System::UnicodeString Value = {read=GetValue};
TGroup() {}
};
プロパティ
種類 | 可視性 | ソース | ユニット | 親 |
---|---|---|---|---|
record struct |
public | System.RegularExpressions.pas System.RegularExpressions.hpp |
System.RegularExpressions | System.RegularExpressions |
説明
1 つの正規表現の一部と一致する結果を含むレコード。
TGroup にはパブリックなコンストラクタがありません。 TGroup のインスタンスは、System.RegularExpressions.TRegEx.Match を呼び出すことによって作成されます。
1 つの正規表現パターンに複数のサブパターンが含まれている場合があります。サブパターンは、その正規表現の一部をかっこで囲むことによって定義されています。 このようなサブパターンは、それぞれ 1 つのサブ表現(グループ)を検出します。 たとえば、正規表現パターン (\d{3})-(\d{2})-(\d{4}) は、社会保障番号と一致します。 第 1 グループは最初の 3 桁で構成され、この正規表現の (\d{3}) の部分によって検出されます。 2 桁の第 2 グループは、この正規表現の (\d{2}) の部分、第 3 グループは (\d{4}) の部分によって検出されます。 この正規表現を利用して、正しい書式の社会保障番号に System.RegularExpressions.TRegEx.Match を実行すると、これら 3 つのグループを TGroupCollection オブジェクトから取得できます。このオブジェクトは、System.RegularExpressions.TMatch.Groups プロパティによって返されます。 個々の TGroup は、Item 配列から取得できます。 その内容は、TGroup の Value プロパティに保持されています。