-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindex.m
23 lines (18 loc) · 821 Bytes
/
findex.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function [ data_str, new_str ] = findex( str, start_tag, end_tag )
%Takes a starting string, starting tag, and ending tag and find the
%string inbetween the two tags. It will then export a new string
%which is the minus that that came before the ending tag.
%%% HANS TRAUTLEIN, CS021
%indexes the first item after the string that was searched for
index_s = strfind(str, start_tag) + length(start_tag);
index_s = index_s(1);
%index last item before the tag
index_e = strfind(str(index_s:end), end_tag) - 2;
index_e = index_e(1);
%the beginning index for the new string we will create soon
new_str_begin = index_s + index_e;
%this is the string between the two tags
data_str = str(index_s:new_str_begin);
%this is our new string with the old part subtracted
new_str = str(new_str_begin:end);
end