I’m looking for a way to scan through a textbox and find the content between two specific words For example, if I had
Num 20 Drawrectangle If num = 20 Drawcircle 20 Drawtriangle 20 20 Endif
I’d be wanting to get the text between the word if and endif.

I’m currently using a for loop to get each line of the textbox and execute each shape one at a time, however I now need to include this ability to use an if style statement within the textbox. How would you guys go about doing something like this? Any advice would be appreciated!

Parse the string using ‘if’ and ‘end if’, as delimeters. Everything in between is what you need.
Much faster then regex, and trivial to do

Currently not on PC, bit I’d Probably go with Regex and a pattern like maybe if(.*?)endif
But I am by far no pro in Regex. Try reading into it if you’d like to. https://docs.microsoft.com/de-de/dotnet/api/system.text.regularexpressions.regex?view=net-5.0

That sounds pretty interesting! I’ll definitely look into doing it that way. If you were doing it this way would you find the if-endif before looping through the rest of the program for the other shapes?

source