From a51787d899920a394968f713689307c826068c79 Mon Sep 17 00:00:00 2001 From: Armando Rivera Date: Wed, 31 Oct 2018 23:49:20 -0400 Subject: [PATCH] Add GRAB$ to find and extract strings between two delimiters --- runtime.inc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runtime.inc b/runtime.inc index fb17571..561a926 100644 --- a/runtime.inc +++ b/runtime.inc @@ -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)); +} \ No newline at end of file