How can extract specific numbers from a string???
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Thimiod Athan
am 9 Sep. 2016
Kommentiert: Thimiod Athan
am 9 Sep. 2016
I have the string c={ 4 of 5 stars, 5 of 5 stars, 5 of 5 stars, 3 of 5 stars, 3 of 5 stars, 4 of 5 stars}. How can extract to a matrix the bold numbers ????
thank you!!!
0 Kommentare
Akzeptierte Antwort
Guillaume
am 9 Sep. 2016
str = 'c={ 4 of 5 stars, 5 of 5 stars, 5 of 5 stars, 3 of 5 stars, 3 of 5 stars, 4 of 5 stars}';
starcount = str2double(regexp(str, '\d+(?= of)', 'match'))
The regular expression matches any sequence of digit immediately followed by ' of'.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!