System.RegularExpressions.TMatch

De RAD Studio API Documentation
Aller à : navigation, rechercher

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() {}
};

Propriétés

Type Visibilité  Source Unité  Parent
record
struct
public
System.RegularExpressions.pas
System.RegularExpressions.hpp
System.RegularExpressions System.RegularExpressions

Description

Un enregistrement contenant les résultats d'une correspondance d'expression régulière unique.

TMatch n'a pas de constructeur public. TMatch est construit par des méthodes telles que System.RegularExpressions.TRegEx.Match en tant que valeur de retour qui représente la première correspondance d'un modèle dans une chaîne. TMatch est aussi le type de retour de NextMatch. System.RegularExpressions.TRegEx.Matches renvoie un TMatchCollection qui contient toutes les correspondances trouvées.

Si une correspondance de modèle a réussi, la propriété Value contient la sous-chaîne correspondante, la propriété Index contient la position de début d'index basé sur zéro de la sous-chaîne correspondante dans la chaîne d'entrée, et la propriété Length contient la longueur de la sous-chaîne correspondante dans la chaîne d'entrée.

Puisqu'une correspondance unique peut impliquer plusieurs groupes de capture, TMatch a une propriété Groups qui est de type TGroupCollection.

Voir aussi