Page 2 of 2

Re: Easier way to do this? Find variables in text

Posted: Mon May 06, 2019 12:27 pm
by kaveh1000
Here is a minimal stack that does the job using regex

Re: Easier way to do this? Find variables in text

Posted: Mon May 06, 2019 2:57 pm
by Thierry
kaveh1000 wrote:
Mon May 06, 2019 12:27 pm
Here is a minimal stack that does the job using regex

Hi Kaveh,

If you don't mind,
here is a slightly optimized and less verbose version of your code:

Code: Select all

   on mouseup
   local tOriginal, tResult
   put fld "Original" into tOriginal

   repeat forever
      if not matchChunk(tOriginal, "@{(.+?)}", tStart, tEnd) then exit repeat
      put char tStart to tEnd of tOriginal & cr after tResult
      delete char 1 to tEnd of tOriginal
   end repeat

   delete last char of tResult
   put tResult into fld "Result"
end mouseup
Regards,

Thierry

Re: Easier way to do this? Find variables in text

Posted: Mon May 06, 2019 3:20 pm
by kaveh1000
Wonderful. Much better. Thanks Thierry. :-) Easier to read too!!