how to get mid() and/or substring?

Monkey Forums/Monkey Programming/how to get mid() and/or substring?

Salmakis(Posted 2013) [#1]
Hey, am i blind?
or does the String class really dont have a .mid() or substring() method?

actually i do it this way:

Local chars:int[] = str.ToChars()
chars = chars.Resize(chars.Length() -1)
str= String.FromChars(chars)


(in this case to remove the last char of the string)

is there any nicer way?


Midimaster(Posted 2013) [#2]
But we have slicing:

Global Whole$, Part$
Whole="abcdef"
Part=Whole[2..3]



See manual part "Language Reference" chapter "The String Type"


Shagwana(Posted 2013) [#3]
If it helps, you can also...
Print "abcdefg"[..4]
Print "abcdefg"[4..]

Local i:Int=4
Print "abcdefg"[i..]