Extract words between characters.
이전 댓글 표시
Im trying to copy words from item.txt file and put them into an index matrix (show me the location of each word), copy the entire string between a bunch of characters and store the string into one matrix.
I already have a program that do something similar, the results of the following program is attached into "results.jpg".
What i want now is to copy the words between the characters "//================..." and store each word into a matrix . The first result would be the word "Blink dagger". The words between "//================..." are always different. The file "items.txt" is also attached.
// DOTA_ABILITY_BEHAVIOR_DIRECTIONAL = 1024 : This ability has a direction from the hero
// DOTA_ABILITY_BEHAVIOR_IMMEDIATE = 2048 : This ability does not interrupt other abilities
//
//=================================================================================================================
// Blink dagger
//=================================================================================================================
"item_blink"
{
// General
//-------------------------------------------------------------------------------------------------------------
-
function x=item_dota()
fid = fopen('items.txt') ;
S = textscan(fid,'%s','delimiter','\n') ;
S = S{1} ;
idx = strfind(S, '"ItemCost"');
idx = find(not(cellfun('isempty',idx)));
ACD = S(idx);
b=regexp(ACD,'\d+(\.)?(\d+)?','match');
iwant=str2double([b{:}]);
y=size(iwant);
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!