System.RegularExpressions.TGroupCollection
Delphi
TGroupCollection = record
C++
struct DECLSPEC_DRECORD TGroupCollection
{
public:
TGroup operator[](const int Index) { return this->Item[Index]; }
private:
System::DynamicArray<TGroup> FList;
System::_di_IInterface FNotifier;
protected:
__fastcall TGroupCollection(const System::_di_IInterface ANotifier, const System::UnicodeString AValue, int AIndex, int ALength, bool ASuccess);
private:
int __fastcall GetCount();
TGroup __fastcall GetItem(const int Index)/* overload */;
TGroup __fastcall GetItem(const System::UnicodeString Index)/* overload */;
bool __fastcall GetNamedGroupIndex(const System::UnicodeString Index, /* out */ int &IntIndex);
public:
bool __fastcall TryGetNamedGroup(const System::UnicodeString Index, /* out */ TGroup &Group);
bool __fastcall ContainsNamedGroup(const System::UnicodeString Index);
TGroupCollectionEnumerator* __fastcall GetEnumerator();
__property int Count = {read=GetCount};
__property TGroup Item[const int Index] = {read=GetItem};
TGroup operator[](const System::String Index) { return GetItem(Index); };
TGroupCollection() {}
};
プロパティ
種類 | 可視性 | ソース | ユニット | 親 |
---|---|---|---|---|
record struct |
public | System.RegularExpressions.pas System.RegularExpressions.hpp |
System.RegularExpressions | System.RegularExpressions |
説明
1 つの正規表現と一致した結果のグループの集合です。
TGroupCollection にはパブリックなコンストラクタがありません。 TGroupCollection のインスタンスは、System.RegularExpressions.TRegEx.Match の呼び出しの中で作成され、System.RegularExpressions.TMatch.Groups の呼び出しの中でアクセスされます。
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 プロパティに保持されています。