String parsing with a delimiter
Show older comments
Hello, I’m having a little problem parsing a string using a delimiter. It leave the delimiter attached to my string. Here’s my code:
str = ‘counter=10;count=7;’;
[token, remain] = strtok(str, '=');
switch token
case 'counter'
[token1, remain1] = strtok(remain, ';');
counter = str2double(token1);
end
token comes out right but remain has the value of “=10;count=7;” so when I do my next strtok my token1 has a value of “=10”’. Is there any way to parse to a delimiter and remove it from my string in matlab? Thanks.
Accepted Answer
More Answers (1)
Matt Kindig
on 16 May 2012
What is your desired output? You might be able to do this easier with regular expressions.
doc regexp
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!