tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelecttuple_regexp_select (Operator)

Name

tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelecttuple_regexp_select — Auswählen von Tupelelementen, die einem regulären Ausdruck entsprechen.

Signatur

tuple_regexp_select( : : Data, Expression : Selection)

Herror tuple_regexp_select(const char* Data, const char* Expression, char* Selection)

Herror T_tuple_regexp_select(const Htuple Data, const Htuple Expression, Htuple* Selection)

void TupleRegexpSelect(const HTuple& Data, const HTuple& Expression, HTuple* Selection)

HTuple HTuple::TupleRegexpSelect(const HTuple& Expression) const

static void HOperatorSet.TupleRegexpSelect(HTuple data, HTuple expression, out HTuple selection)

HTuple HTuple.TupleRegexpSelect(HTuple expression)

def tuple_regexp_select(data: MaybeSequence[str], expression: MaybeSequence[str]) -> Sequence[str]

def tuple_regexp_select_s(data: MaybeSequence[str], expression: MaybeSequence[str]) -> str

Beschreibung

tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelectTupleRegexpSelecttuple_regexp_select wendet den regulären Ausdruck ExpressionExpressionExpressionExpressionexpressionexpression auf eine oder mehrere Zeichenketten in DataDataDataDatadatadata an, und gibt die Elemente, die eine dem Suchmuster entsprechende Teilzeichenkette enthalten, in SelectionSelectionSelectionSelectionselectionselection zurück. Dies ist ein bequemer Weg, um z.B. ein über den Operator list_fileslist_filesListFilesListFilesListFileslist_files erhaltenes Tupel von Dateinamen zu filtern.

Für die Beschreibung von Syntax und Optionen des regulären Ausdrucks wird auf die Dokumentation des Operators tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatchTupleRegexpMatchtuple_regexp_match verwiesen. Zusätzlich unterstützt der Operator tuple_regexp_testtuple_regexp_testTupleRegexpTestTupleRegexpTestTupleRegexpTesttuple_regexp_test noch die Option 'invert_match'"invert_match""invert_match""invert_match""invert_match""invert_match", mit der die Elemente ausgewählt werden, die dem Suchmuster nicht entsprechen.

Für allgemeine Informationen zu String-Operationen siehe auch Tupel / String-Operationen.

Falls das Eingabetupel leer ist, gibt der Operator ein leeres Tupel zurück.

Unicode Codepoints versus Bytes

Die Auswertung der regulären Ausdrücke berücksichtigt Unicode Codepoints. Ein Codepoint kann aus mehreren Bytes im UTF-8 String zusammengesetzt sein. Wenn die Auswertung der regulären Ausdrücke sich auf die Bytes des Strings beziehen soll, kann dieser Operator mit set_system('tsp_tuple_string_operator_mode','byte')set_system("tsp_tuple_string_operator_mode","byte")SetSystem("tsp_tuple_string_operator_mode","byte")SetSystem("tsp_tuple_string_operator_mode","byte")SetSystem("tsp_tuple_string_operator_mode","byte")set_system("tsp_tuple_string_operator_mode","byte") in einen Byte-Modus umgeschaltet werden. Wenn 'filename_encoding'"filename_encoding""filename_encoding""filename_encoding""filename_encoding""filename_encoding" auf 'locale'"locale""locale""locale""locale""locale" gesetzt ist (legacy), verwendet dieser Operator immer den Byte-Modus.

HDevelop Inline-Operation

HDevelop unterstützt eine Inline-Operation für tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelectTupleRegexpSelecttuple_regexp_select, die innerhalb eines Ausdrucks in der folgenden Syntax verwendet werden kann:

Selection := regexp_select(Data, Expression)

Ausführungsinformationen

Parameter

DataDataDataDatadatadata (input_control)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Eingabezeichenketten, auf die das Suchmuster angewendet wird

ExpressionExpressionExpressionExpressionexpressionexpression (input_control)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Regulärer Ausdruck.

Defaultwert: '.*' ".*" ".*" ".*" ".*" ".*"

Wertevorschläge: '.*'".*"".*"".*"".*"".*", 'invert_match'"invert_match""invert_match""invert_match""invert_match""invert_match", 'ignore_case'"ignore_case""ignore_case""ignore_case""ignore_case""ignore_case", 'multiline'"multiline""multiline""multiline""multiline""multiline", 'dot_matches_all'"dot_matches_all""dot_matches_all""dot_matches_all""dot_matches_all""dot_matches_all", 'newline_lf'"newline_lf""newline_lf""newline_lf""newline_lf""newline_lf", 'newline_crlf'"newline_crlf""newline_crlf""newline_crlf""newline_crlf""newline_crlf", 'newline_cr'"newline_cr""newline_cr""newline_cr""newline_cr""newline_cr"

SelectionSelectionSelectionSelectionselectionselection (output_control)  string(-array) HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Zeichenketten mit Übereinstimmung

Beispiel (HDevelop)

tuple_regexp_select (['.','..','mydir','a.png','b.txt','c.bmp','d.dat'], \
                     '.(bmp|png)', Result)
* Returns ['a.png','c.bmp']

tuple_regexp_select (Files, ['training','invert_match'], Matches)
* Returns all file names that do *not* contain the string 'training'

Alternativen

tuple_selecttuple_selectTupleSelectTupleSelectTupleSelecttuple_select

Siehe auch

tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatchTupleRegexpMatchtuple_regexp_match, tuple_regexp_replacetuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplaceTupleRegexpReplacetuple_regexp_replace, tuple_regexp_testtuple_regexp_testTupleRegexpTestTupleRegexpTestTupleRegexpTesttuple_regexp_test

Modul

Foundation