Extract Variables from mixed string
Ältere Kommentare anzeigen
Hi all,
In this string
'# Message: onset_pic1_8.png'
how can I read 'onset', 'pic', '1', '8' in four variables?
1 Kommentar
dpb
am 12 Aug. 2018
Use regexp
Akzeptierte Antwort
Weitere Antworten (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.
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!