Strings and pattern matching

BlitzMax Forums/BlitzMax Beginners Area/Strings and pattern matching

Is there some function in BMax to manipulate strings like "scanf" function of C?

Or

Is there something similar to the pattern matching of OcaML?

the prblem is:

if i have a string "if(condition)then commands else commands endif",
how can i get an array with [condition, commands, commands] strings?

something like

mystring.isLike("if(*)then*else*endif") returning a string array with "*" strings?

or something like

match mystring with:
| if(b)then c else c2 -> [b, c, c2]

?

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


great!

so i can use string as arrays!

very good