|
In article <fmqt09$mtb$1@fred.mathworks.com>, Pete sherer <tsh@abg.com> wrote:
>I have character data like:
>aa = {'BI234','EVB67','C4566','St Vermont','DD'};
>How can I use REGEXP to separate the character and the number?
>so
>aa1 = {'BI','EVB','C','St Vermont','DD'};
>aa2 = {'234','67','4566','',''};;
Well, you could certainly do it with regexp, but if those
strings illustrate the complete range of variations, then why not
use find(ismember(aa{i}, '0':'9'), 1) to find the index
of the first digit in aa{i} ? If you need to run over the entire
aa cell, you can either loop or cellfun() with UniformOutput 0 .
Note: the output of the find() will be empty for strings without digits.
--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec
|