A Petrov
A Petrov

Reputation: 474

Display only INT in matlab

Long story short - I've got code that displays (using disp) something like this

CLCC, OK, VOICE, +359888888888, CLCC, OK

How can I make it so it will only display

+359888888888

Perhaps slicing the string could work, but isn't there an easier way?

Upvotes: 0

Views: 138

Answers (1)

Rody Oldenhuis
Rody Oldenhuis

Reputation: 38032

I can think of a few ways:

% your string
a = 'CLCC, OK, VOICE, +359888888888, CLCC, OK';

% parse it
C = textscan(a, '%*s%*s%*s%u64%*s%*s');
C{1} % uint64, probably not the best choice given that it's a phone number...

% index it
a(18:30) % char

% match it
char(regexp(a, '[1-9+]*', 'match')) % char

...Depending of course on whether this is all there is to your string :)

Upvotes: 1

Related Questions