Filter löschen
Filter löschen

how to split a string at apostrophe using strsplit

6 Ansichten (letzte 30 Tage)
Abhinav
Abhinav am 2 Mär. 2018
Kommentiert: Jan am 2 Mär. 2018
I have a string '40°50'24', I want to separate the string at '&#176' and apostrophe between 50 and 24. Therefore, I am expecting 40, 50 and 24 in separate cells. But I am not able to separate the apostrophe using strsplit. Is there a way to do it?

Akzeptierte Antwort

Akira Agata
Akira Agata am 2 Mär. 2018
You should repeat apostrophe to represent apostrophe in MATLAB, like:
>> S='I''m fine!'
S =
'I'm fine!'
So, regarding your question, please try the following:
>> strsplit(str,{'°',''''})
ans =
1×3 cell array
{'40'} {'50'} {'24'}
  2 Kommentare
Jan
Jan am 2 Mär. 2018
I prefer char(39) instead of ''''. As soon as you are searching for 2 quotes, char([39, 39]) is much better than ''''''.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by