function SST = strrep_sst(s1,s2,ALF) % creates a subsequential transducer that replaces % all occurrences of str s1 with str s2 % these have no accept states n = length(s1); SST.ALF = ALF; SST.Q = 1:n; SST.q0 = 1; for i=1:n for sig=ALF if (sig==s1(i)) if (i==n) % we've read in the whole s1 -- emit s2 and return to state 1 SST = set_sstd(SST,n,sig,1,s2); else % we're somewhere in the middle of s2 -- emit nothing for now SST = set_sstd(SST,i,sig,i+1,''); end else SST = set_sstd(SST,i,sig,1,[s1(1:i-1) sig]); end end end return function junk sigs = setstar(ALF); MM = null_dfsa(ALF); for j=1:length(s1) u = s1(1:j); reg = [sigs u ]; M = gregexp2dfsa_fast(reg,ALF); MM = union_dfsa(MM,M); end % accept states of Mu emit s2 return