Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: how to extract consecutive digits of a known length in a string
Posted:
Nov 12, 2012 12:47 PM


In article <k7qt7u$t34$1@newscl01ah.mathworks.com>, "Ha " <scifiles@126.com> wrote:
> E.g., > s = 'xasdf.123456.dkkk'; > s = '342456.xkkd.sdf23.456..dd'; > > I wanna get the six successive digits from such strings. I guess regular > expression can handle this problem but don't know how.
regexp(s,'\d{6}','match')
will find six digits in a row, but do you want it to fail if there happen to be seven? That line will find the first six, but you would have to do something more elaborate to exclude cases of more than six.
 Doug Schwarz dmschwarz&ieee,org Make obvious changes to get real email address.



