Extract Variables from mixed string
显示 更早的评论
Hi all,
In this string
'# Message: onset_pic1_8.png'
how can I read 'onset', 'pic', '1', '8' in four variables?
采纳的回答
更多回答(1 个)
You can use:
mystring = '# Message: onset_pic1_8.png';
matches = regexp(mystring,'\d|[a-z]+(?=_|\d)','match')
>>matches
{'onset'} {'pic'} {'1'} {'8'}
To obtain the values.
You can't use 1 and 8 as variable names.
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!