From: per isakson on 3 Jul 2010 11:52 "lily " <mediocrity111(a)hotmail.com> wrote in message <i0n14d$ecp$1(a)fred.mathworks.com>... > My question is how to use function regexprep to replace a whole string with a part of it. > K>> str='a_b_c.3d.6';regexprep(str,'\w?_(\w+)_\w+?','$1') > ans = > b.3d.6 > What I want is only ‘b’,how to define the pattern?Thanks. >> str='a_b_c.3d.6';regexprep(str,'\w?_(\w+)_.+','$1') ans = b >> I guess \w doesn't match "." / per
|
Pages: 1 Prev: Problem in reading FITS file from fitsread. Next: Thanks Re: pre-allocation question |