MATLAB: String parsing

string parsing

input string s='Temp : 34, Altitude : 35, Pressure : 45' . I now want to store Temp, Alt and Pressure value in three different Strings. How to do the parsing in this case..??? Pls help.

Best Answer

It kinda depends on how flexible you need to be. Are the tags ever in a different order? Is the format EXACTLY as given? Are the numbers always integers?
Something as simple as this could work:
sscanf(s, 'Temp : %f, Altitude : %f, Pressure : %f')
[EDIT] Oh, sorry, you said "strings":
regexp(s, ':\s*(\d+),.*:\s*(\d+),.*:\s*(\d+)', 'tokens')