string s = "top.block_name.subblock_name";
and I want to extract the block_name from the string, how would I do
it?
I know there's a substr function
s.substr()
but there's no find() function to locate the . (dot) separator.
Thanks!
You can always write your own find function:
function int find(int offset, string s);
int i;
for (i = offset; i < s.len(); i=i+1)
if (s.getc(i) == '.')
find = i;
return;
endfunction
and use it as following:
int firstdot = find(0,s)+1;
int nextdot = find(firstdot,s);
string blockname = s.substr(firstdot, nextdot);
Standard disclaimer: this is non-tested code which means most probably
it won't even compile at first try. Making it work is left as an
exercise for the reader.