From: us on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i1ao6l$msu$1(a)fred.mathworks.com>...
> Dear Adrian,
>
> It is easy to pretend a solution:
> S = 'Take me home, cas<<ountry rosd<<ad.';
> S2 = strrep(S, '<', char(8));
> disp(S2)
> >> Take me home, country road.
>
> But the truth is revealed by inspecting S2:
> length(S2)
> >> 35
> So the backspaces (CHAR(8)) and the shadowed characters are still existing.
>
> I didn't find a solution to read the cleaned printed string. Neither SPRINTF, nor EVALC(DISP) nor FPRINTF to a file or the command window worked - the CHAR8) are still there. I had success using the java.awt.robot simulating keyboard clicks, but this looks even more puzzling than Matt Figs solution ("as someone had rolled an angry armadillo over the keyboard").
>
> Kind regards, Jan

but... the above solutions (seems) to work...
% use BS char instead of '<'...

s='Take meX< home, cas<<ountry rosdXX<<<<ad.';
bs=char(8);
s=strrep(s,'<',bs);
ix1=strfind(s,bs);
ss='';
while true
ss=regexprep(s,['(\w{1,1}',bs,')'],'');
if isequal(ss,s)
break;
end
s=ss;
end
ix2=strfind(s,bs);
ix1
ix2
%{
% ix1 =
9 20 21 35 36 37 38
% ix2 =
[]
%}

us
From: Jan Simon on
Dear us,

> but... the above solutions (seems) to work...
> while true
> ss=regexprep(s,['(\w{1,1}',bs,')'],'');
> if isequal(ss,s)
> break;
> end
> s=ss;
> end

Of course this works. And it is easy to understand, modify and debug (if it would have a bug).
I'm just disappointed, that the simple FPRINTF *can* perform the conversion when printing to the command line, but I cannot catch the result to a string again.

Jan
From: us on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i1asb9$h6$1(a)fred.mathworks.com>...
> Dear us,
>
> > but... the above solutions (seems) to work...
> > while true
> > ss=regexprep(s,['(\w{1,1}',bs,')'],'');
> > if isequal(ss,s)
> > break;
> > end
> > s=ss;
> > end
>
> Of course this works. And it is easy to understand, modify and debug (if it would have a bug).
> I'm just disappointed, that the simple FPRINTF *can* perform the conversion when printing to the command line, but I cannot catch the result to a string again.
>
> Jan

but jan...
you simply cannot have if all:
- either germany wins a great(!) third...
- or ML provides a solution to this conundrum...

now, let's see what paul did: he/she/most likely it(!) voted for #1...

:-)
urs
From: Matt Fig on
How about a drunk and angry armadillo with a hatred of multiple lines?



% DATA
STR = 'Take me homeuuu<<<, cas<<ountry rosd<<ad.'

% ENGINE
STR(cell2mat(cellfun(@(x)x(1)-diff(x)-1:x(2),regexp(STR,'(<)+','tokenExtents'),'Un',0))) = ''
From: us on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <i1atq4$r6k$1(a)fred.mathworks.com>...
> How about a drunk and angry armadillo with a hatred of multiple lines?

%{
> % DATA
> STR = 'Take me homeuuu<<<, cas<<ountry rosd<<ad.'
> % ENGINE
> STR(cell2mat(cellfun(@(x)x(1)-diff(x)-1:x(2),regexp(STR,'(<)+','tokenExtents'),'Un',0))) = ''
%}

clearly an armadillo about to loose its drivers license...

:-)
us