From: per isakson on
"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 &#8216;b&#8217;,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