#module
#defcfunc removechar str string, str string2, local tmp, local s, local null, local cx, local cy, local tmpid, local sels, local sele
sdim tmp, strlen(string) * 2 + 1
s = string
null = ""
cx = ginfo_cx : cy = ginfo_cy
pos 0, -ginfo_dispy : mesbox s : tmpid = stat
pos cx, cy
repeat
chk = instr(s, , string2)
if chk = -1 : break
cnvstow tmp, s
// 文字単位で開始位置を処理する
sels = 0
repeat chk
sels++ : if peek(tmp, sels * 2 + 1) { continue cnt + 2 }
loop
// 文字単位で終了位置を処理する
sele = sels
repeat strlen(string2)
sele++ : if peek(tmp, sele * 2 + 1) { continue cnt + 2 }
loop
sendmsg objinfo(tmpid, 2), 0x00B1, sels, sele // 選択
sendmsg objinfo(tmpid, 2), 0x00C2, 0, "" // 削除
loop
clrobj tmpid, tmpid
return s
#global
data = "となりの きゃくは よく かきくう きゃくだ\n"
data += "あおまきがみ あかまきがみ きまきがみ"
dchr = "き"
pos 10, 10 : mes data
pos 10, 50 : mes "除去データ:" + dchr
pos 10, 70 : mes "["+removechar(data, dchr)+"]" // 指定文字列から指定文字列を削除する
|