Extract words between characters.
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!