From: Tom Toner on 25 Feb 2010 12:50 Here is my solution, str0 = '0010210020010000200000012102' [mstr,sstr] = regexp(str0, '1[0]+2', 'match', 'split'); mstr1 = regexprep(mstr,'0','3'); str1 = [sstr; [mstr1 {''}]]; str = [str1{:}] Results: str0 = 0010210020010000200000012102 str = 0013213320013333200000012132 However, I was wondering if there were better solutions. Thanks,
|
Pages: 1 Prev: Replace strings without loop Next: fast binary to decimal matrix question |