且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在MATLAB中将字符串解析为字母,数字等?

更新时间:2023-01-16 11:16:08

我认为使用函数哪个会给您这些结果:

alphaStr = 'hjbni'
digitStr = '1242343'
otherStr = '&&(*&'

如果您真的想使用 REGEXP ,这是您的操作方式:

If you really wanted to use REGEXP, this is how you could do it:

matches = regexp(str,{'[a-zA-Z]','\d','[^a-zA-Z\d]'},'match');
alphaStr = [matches{1}{:}];
digitStr = [matches{2}{:}];
otherStr = [matches{3}{:}];