how to split a string at apostrophe using strsplit

조회 수: 13 (최근 30일)
Abhinav
Abhinav 2018년 3월 2일
댓글: Jan 2018년 3월 2일
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?

채택된 답변

Akira Agata
Akira Agata 2018년 3월 2일
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
Abhinav
Abhinav 2018년 3월 2일
Thanks!
Jan
Jan 2018년 3월 2일
I prefer char(39) instead of ''''. As soon as you are searching for 2 quotes, char([39, 39]) is much better than ''''''.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by