From: us on
"Jan Simon"
> It fails if the last character of S is a space.
> Kind regards, Jan

....or any other whitespace; in particular: a TAB,...

us
From: Jan Simon on
Dear Urs!

> > It fails if the last character of S is a space.
> > Kind regards, Jan

> ...or any other whitespace; in particular: a TAB,...
> us

I don't understand. This does not fail, if the last character is a TAB:
ind = [1, findstr(S, ' ') + 1];
Do you mean:
ind = [1, find(isspace(S)) + 1]
?!

confused, Jan
From: us on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hmtv45$73g$1(a)fred.mathworks.com>...
> Dear Urs!
>
> > > It fails if the last character of S is a space.
> > > Kind regards, Jan
>
> > ...or any other whitespace; in particular: a TAB,...
> > us
>
> I don't understand. This does not fail, if the last character is a TAB:

yes, but if there's any TAB between other chars...

s=lower(sprintf('BLUE\tRED\tGREEN\t'));
ix=[1,strfind(s,' ')+1];
s(ix)=upper(s(ix))
% s = Blue red green

us
From: Doug Schwarz on
In article <hmu5o3$pkj$1(a)fred.mathworks.com>,
"us " <us(a)neurol.unizh.ch> wrote:

> "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message
> <hmtv45$73g$1(a)fred.mathworks.com>...
> > Dear Urs!
> >
> > > > It fails if the last character of S is a space.
> > > > Kind regards, Jan
> >
> > > ...or any other whitespace; in particular: a TAB,...
> > > us
> >
> > I don't understand. This does not fail, if the last character is a TAB:
>
> yes, but if there's any TAB between other chars...
>
> s=lower(sprintf('BLUE\tRED\tGREEN\t'));
> ix=[1,strfind(s,' ')+1];
> s(ix)=upper(s(ix))
> % s = Blue red green
>
> us

How about a modification of Urs' original idea? If I have my regular
expression skills in order, this should look for any contiguous block of
non-whitespace and make the first character upper case and any
subsequent characters lower case:

str = 'rED GrEEn BluE';
regexprep(str,'(\S)(\S*)','${upper($1)}${lower($2)}')

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
First  |  Prev  | 
Pages: 1 2
Prev: Call by reference / references
Next: matlab function