#module
#deffunc strrep val, val
mref s, 24 : mref keyword, 57
i = 0, 0 // 検索開始位置, 検索結果
strlen i.2, keyword.0
strlen i.3, keyword.1
strlen i.4, s
sdim tmp, i.4
repeat
instr i.1, s, keyword.1, i.0
if i.1 = -1 : break
i += i.1
strmid tmp, s, , i.0
strlen i.4, s
strmid s, s, i.0 + i.3, i.4 - i.0 - i.3
s = tmp + keyword.0 + s
i += i.2
loop
return
#global
sdim string, 128 // もし変換後サイズが変数サイズを超える場合は大きめに確保しておくこと
sdim word, 16, 2
string = "すもももももももものうち"
word = "も", "もも" // 要素0に置換後、要素1に置換前の文字列を指定する
strrep string, word // 対象ワードを置き換える
dialog string
|