StringField(String$, -1, Delimiter$)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

StringField(String$, -1, Delimiter$)

Post 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
Max.²
Enthusiast
Enthusiast
Posts: 175
Joined: Wed Jul 28, 2004 8:38 am

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

Post 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
Post Reply