|
help regexp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clear
clc
str1='H100L200';
a1=regexp(str1,'[0-9]');
% num1=str1(a1); 提取离散数字
aa1=diff(a1);
num1=[];
num=zeros(1,length(a1));
j=1;
for i=1:length(aa1)
if aa1(i)==1
num1=[num1,str1(a1(i))];
else
num1=[num1,str1(a1(i))];
num(j)=str2num(num1);
j=j+1;
num1=[];
end
if (i==length(aa1)) && (aa1(end)==1)
num1=[num1,str1(a1(length(aa1)+1))];
num(j)=str2num(num1);
end
end
clear num1
disp(num)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100 200 0 0 0 0 |
评分
-
1
查看全部评分
-
|