Page 1 of 1

StringField(String$, -1, Delimiter$)

Posted: Thu Dec 09, 2004 6:09 pm
by Justin
Return the last string field when passing -1 index, done in an efficient way start parsing at the end of the string

it comes handy to get fileextensions or filenames from urls

StringField("http://host.com/file.htm", -1, "/")

StringField("c:\foo\file.ext", -1, ".")

i know there are several ways for this(don't need to post code), but it seems StringField() is well suited for it

Re: StringField(String$, -1, Delimiter$)

Posted: Thu Dec 16, 2004 10:09 pm
by Max.²
Justin wrote:Return the last string field when passing -1 index, done in an efficient way start parsing at the end of the string

it comes handy to get fileextensions or filenames from urls

StringField("http://host.com/file.htm", -1, "/")

StringField("c:\foo\file.ext", -1, ".")

i know there are several ways for this(don't need to post code), but it seems StringField() is well suited for it
I like that and would even like more if it was a bit extended.

Either using your syntax, giving the possibility of using also -2,-3,...,-n to get the 2nd, 3rd or whatsoever field from the right or adding an optional parameter.:

Result$ = StringField(String$, Index, Delimiter$[,Mode])

0 (default) - from left to right
1 - from right to left