Find string and get number from a Cell array of strings.

1 view (last 30 days)
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?

Accepted Answer

Guillaume
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.

More Answers (0)

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!