イフコンピュータ > MINERVA > マニュアル > レファレンス > 述語 > 文書処理と正規表現 > substitute/4

substitute/4

MINERVA
ifcomputer logo
f
Expert Services on the Web

部分文字列を取り替えます

substitute(+regexp, +string, +substitution, -result)

substitute/4は、"string"の中で"regexp"によって定義される部分列を"substitution"と取り替えます。 修正された文字列は、"result"で復帰されます

引き数

	regexp		アトム
	string		アトム
	substitution	アトム
	result		アトム

例題

例えば、語の位置を交換する
	substitute('(%w+) (%w+)', 'one two', '%2 %1', L).
		==> L = 'two one'

括弧に入れられたものは何でも、項に割り当てられます。 左から右にi番目の開いた括弧によって括弧に入れられたものは、i番目の項に割り当てられます。 括弧に入れられた項は、substitute/4とsubstitute_all/4において、ubstitute表現の中で%1...%9で参照つけられることができます。

規格

この述語は、ISO-Prolog Standardの要件ではありません。

以下も参照して下さい

正規表現, match/2/3, match_all/3, substitute/4, substitute_all/4, split/2/3, chop/2, get_line/1/2,

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/regexp/substitute/print_jp.html
published 2008/10/6 update 1999/5/10 (c) 1996-2006 IF Computer Japan
IF Computer 〒113-0022 Tel 03-5814-3352 start (AT) ifcomputer.com
Customer Support 東京都文京区千駄木5-28-2   http://www.ifcomputer.co.jp
戻る> managed with ubiCMS