When I try to perform a string replace as in the example below (with strings of repeating characters), MATLAB provides an unexpected result. It replaces each character in the string rather than the entire string.
x = 'abcd 2 efgh 22 ijkl 222 mnop 2222 qrst 22222 uvw 222222 xyz'y = strfind(x, '22')z = strrep(x, '22', '*')
results in:
x = abcd 2 efgh 22 ijkl 222 mnop 2222 qrst 22222 uvw 222222 xyz y = 13 21 22 30 31 32 40 41 42 43 50 51 52 53 54 z = abcd 2 efgh * ijkl ** mnop *** qrst **** uvw ***** xyz
Best Answer