extract numbers from string in a cell
Show older comments
Hi, I have a cell containing a string such as 'TT21abc.def'. I want to extract just the numbers so I'm left with '21'. Does anyone know how? I tried using sscanf but I was getting errors and think I don't have the right format inputs. Thanks in advance.
Accepted Answer
More Answers (1)
Andrei Bobrov
on 8 May 2012
with using function regexp
regexp(a,'\d*','match')
or:
b = {'TT21abc.def'
'sdfsdf34435afafsd.,.,3434'}
out = regexp(b,'\d*','match');
out = cat(2,out{:})
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!