Easier way to do this? Find variables in text
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: Easier way to do this? Find variables in text
Here is a minimal stack that does the job using regex
- Attachments
-
- extract.zip
- (1.21 KiB) Downloaded 144 times
Kaveh
Re: Easier way to do this? Find variables in text
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
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: Easier way to do this? Find variables in text
Wonderful. Much better. Thanks Thierry. Easier to read too!!
Kaveh