Add GRAB$ to find and extract strings between two delimiters

This commit is contained in:
Armando Rivera 2018-10-31 23:49:20 -04:00
parent ad83fc3aff
commit a51787d899

View File

@ -242,3 +242,11 @@ ENDFUNCTION
FUNCTION INT VAL (CSTRING str) BEGIN
RETURN atoi(str.c_str());
ENDFUNCTION
FUNCTION CSTRING GRAB$(CONSTANT CSTRING &src, CONSTANT CSTRING &start, CONSTANT CSTRING &stop) {
DIM AS size_t begin = src.find(start);
DIM AS size_t end = (begin + start.length());
DIM AS size_t term = src.find(stop);
return src.substr(end, (term - end));
}