Skip to content

tuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplacetuple_regexp_replacetuple_regexp_replace🔗

説明🔗

tuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplacetuple_regexp_replacetuple_regexp_replace — 正規表現を使用して従属文字列を置換する。

書式🔗

tuple_regexp_replace( string Data, string Expression, string Replace, out string Result )void TupleRegexpReplace( const HTuple& Data, const HTuple& Expression, const HTuple& Replace, HTuple* Result )static void HOperatorSet.TupleRegexpReplace( HTuple data, HTuple expression, HTuple replace, out HTuple result )def tuple_regexp_replace( data: MaybeSequence[str], expression: MaybeSequence[str], replace: str ) -> Sequence[str]

def tuple_regexp_replace_s( data: MaybeSequence[str], expression: MaybeSequence[str], replace: str ) -> strHerror tuple_regexp_replace( const char* Data, const char* Expression, const char* Replace, char* Result )

Herror T_tuple_regexp_replace( const Htuple Data, const Htuple Expression, const Htuple Replace, Htuple* Result )

HTuple HTuple::TupleRegexpReplace( const HTuple& Expression, const HTuple& Replace ) const

HTuple HTuple.TupleRegexpReplace( HTuple expression, HTuple replace )

説明🔗

tuple_regexp_replaceTupleRegexpReplace は、Expressionexpressionexpression の正規表現を Datadatadata 内の複数の入力文字列に適用し、Replacereplacereplace表現を 使用し、最初に一致する従属文字列を置換します。各入力文字 列に対して、処理された出力文字列が、Resultresultresult に返されます。

正規表現のシンタックスやオプションについては、 tuple_regexp_matchTupleRegexpMatch を参照してください。さらに、 tuple_regexp_replaceTupleRegexpReplace はオプション 'replace_all'"replace_all" をサポートしています。これは、各文字列内で一致するすべて を置換します。

Replacereplacereplace 表現は、タグ '$0'"$0" を 使って入力データ内の一致する従属文字列を参照し、'$i'"$i" を使って i 番目のキャプチャグループの従属一致を参 照し(\(i <= 9\))、'$$'"$$" を使って ’$’ リテラルを参照することができます。

文字列操作の概要はTuple / String Operationsをご覧ください。

Datadatadataが空のtupleの場合、この関数は空のtupleを返します。 Replacereplacereplaceが空のtupleで、かつDatadatadataが空でない場合、例外が発生します。

Unicodeコードポイントとバイト🔗

正規表現マッチングは、Unicodeコードポイントで動作します。 1つのUnicodeコードポイントは、UTF-8文字列の複数のバイトで構成されています。 正規表現マッチングがバイトでのみ一致する必要がある場合、 このオペレータは set_system('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")set_system("tsp_tuple_string_operator_mode", "byte") で バイトモードに切り替えることができます。 'filename_encoding'"filename_encoding" が 'locale'"locale"(レガシー)に設定されている場合、 このオペレータは常にバイトモードを使用します。

HDevelopインライン演算🔗

HDevelopは tuple_regexp_replaceTupleRegexpReplace の代わりとなるインライン演算を備えており、以下の構文形式 で使用することができます::

Result := regexp_replace(Data, Expression, Replace)

実行情報🔗

実行情報
  • マルチスレッドタイプ: リエントラント(非排他なオペレーターと並列に動作)

  • マルチスレッドスコープ: グローバル(他のスレッドから呼び出される可能性あり)

  • 並列演算処理には未対応

パラメーター🔗

Datadatadata (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

処理用入力文字列

Expressionexpressionexpression (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

正規表現

初期値: '.*'".*"
推奨値: '.*', 'replace_all', 'ignore_case', 'multiline', 'dot_matches_all', 'newline_lf', 'newline_crlf', 'newline_cr'".*", "replace_all", "ignore_case", "multiline", "dot_matches_all", "newline_lf", "newline_crlf", "newline_cr"

Replacereplacereplace (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

置換表現

Resultresultresult (output_control) string(-array) → (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

処理された文字列

例🔗

(HDevelop)


tuple_regexp_replace(['img10.bmp','img11.bmp','img12.bmp'], \
                     'img(.*).bmp', 'out$1.txt', Result)
* Returns ['out10.txt','out11.txt','out12.txt']

他のオペレーターとの組み合わせ🔗

組み合わせ

関連項目

tuple_regexp_matchTupleRegexpMatch, tuple_regexp_testTupleRegexpTest, tuple_regexp_selectTupleRegexpSelect

モジュール🔗

Foundation