;---------- ---------- ---------- ---------- ---------- ; 作成者のURL ---> http://www.setsuki.com/ ;---------- ---------- ---------- ---------- ---------- #module ;---------- ---------- ---------- ---------- ---------- ; 文字列 subject 中の search を全て replace に置換する ;---------- ---------- ---------- ---------- ---------- #deffunc str_replace var subject, str search, str replace s = strlen(search) r = strlen(replace) f = strlen(subject) i = 0 sdim change, r : change=replace repeat f a = instr(subject, i, search) : if(a<0)||(a+i>=f) : break i+=a if r > s : memexpand subject, f+r-s memcpy subject, subject, f-s-i, i+r, i+s memcpy subject, change , r, i, 0 i+=r : f+=r-s loop memexpand subject, f+1 : poke subject,f return ;---------- ---------- ---------- ---------- ---------- #global ; サンプル buf = "カフェオレが好きなオレ。おれおれオレ?" str_replace buf, "オレ", "(まんじゅう)" : dialog buf