comparison scripts/strings/strrep.m @ 3180:c17387059fd3

[project @ 1998-09-24 18:59:11 by jwe]
author jwe
date Thu, 24 Sep 1998 19:00:19 +0000
parents b5568c31ee2c
children 4f40efa995c1
comparison
equal deleted inserted replaced
3179:f657159c8152 3180:c17387059fd3
44 ind = findstr (s, x, 0); 44 ind = findstr (s, x, 0);
45 len = length (ind); 45 len = length (ind);
46 if (len == 0) 46 if (len == 0)
47 t = s; 47 t = s;
48 else 48 else
49 s = toascii (s); 49 save_empty_list_elements_ok = empty_list_elements_ok;
50 x = toascii (x); 50 unwind_protect
51 y = toascii (y); 51 empty_list_elements_ok = 1;
52 52 l_x = length (x);
53 l_x = length (x); 53 tmp = s (1 : ind (1) - 1);
54 tmp = s (1 : ind (1) - 1); 54 t = strcat (tmp, y);
55 t = [tmp, y]; 55 for k = 1 : len - 1
56 for k = 1 : len - 1 56 tmp = s (ind (k) + l_x : ind (k+1) - 1);
57 tmp = s (ind (k) + l_x : ind (k+1) - 1); 57 t = strcat (t, tmp, y);
58 t = [t, tmp, y]; 58 endfor
59 endfor 59 tmp = s (ind(len) + l_x : length (s));
60 tmp = s (ind(len) + l_x : length (s)); 60 t = [t, tmp];
61 t = [t, tmp]; 61 unwind_protect_cleanup
62 t = setstr (t); 62 empty_list_elements_ok = save_empty_list_elements_ok;
63 end_unwind_protect
63 endif 64 endif
64 65
65 endfunction 66 endfunction