문자열의 각 단어를 어떻게 표시합니까? 루프를 작성했지만 작동하지 않습니다. 당신이 regexp
을 선호하는 경우문자열의 각 단어를 표시하는 방법은 무엇입니까?
>> str='How to display each individual word of a string';
>> words = strsplit(str);
>> words.' %' each word is in a cell (words{1} is first word)
ans =
'How'
'to'
'display'
'each'
'individual'
'word'
'of'
'a'
'string'
또는, 당신은 'split'
keyword 거의 사용하지를 적용 할 수 있습니다 :
>> words = regexp(str,'[\s]','split')
words =
'How' 'to' 'display' 'each' 'individual' 'word' 'of' 'a' 'string'
strsplit 함수가 작동하지 않습니다. – user3281110
최신 MATLAB 버전입니다. 대신에'regexp' 솔루션을 사용하십시오. – chappjc