Strings and pattern matching

BlitzMax Forums/BlitzMax Beginners Area/Strings and pattern matching

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

a simple code

Local MY$ = "If(*)Then*Else*EndIf"



Local res$[] = Extract(my) 
For Local s$ = EachIn res
	Print s
Next




Function Extract$[](text$) 
'find THEN
'find ENDIF

text=Upper(text)

Local f1:Int , f2:Int,f3:Int
f1 = Instr(text , "THEN")
f2 = Instr(text,"ELSE")
f3 = Instr(text , "ENDIF") 


Print f1+" "+f2+" "+f3

Local arr$[3]

arr[0] = text[2..f1 - 1]
arr[1] = text[f1+3..f2 - 1]
arr[2] = text[f2+3..f3 - 1]



Return arr
End Function