Find string and get number from a Cell array of strings.
1 view (last 30 days)
Show older comments
Hey All
I have a Cell array of strings, were i need to find string 'L/12'. I know i can use:
idx = strfind(Str,'L/'); %To find my string
But how can i get the number out of the string after i found the string in my cell array?
0 Comments
Accepted Answer
Guillaume
on 10 Jun 2015
c = {'a string with L/50 to find';
'another with nothing to find';
'and another with L/12 to find'};
number = regexp(c, '(?<=L/)\d+', 'match', 'once')
will extract the number (integer only) after the L/ in each string of the cell array.
0 Comments
More Answers (0)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!