StringField to support string delimeter

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

StringField to support string delimeter

Post by Mistrel »

Currently StringField only splits based on the first character of the delimiter. It would be even more useful if it would split based on whole strings.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: StringField to support string delimeter

Post by DoubleDutch »

+1
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Re: StringField to support string delimeter

Post by akj »

+1 for me also ... but ... there is an easy workaround.
Suppose you wanted the string delimiter to be the three characters " - ", then code like this will do the trick:

Code: Select all

Define string$ = "Cat - sat - on - mat"
Define temp$, i
temp$ = ReplaceString(string$, " - ", Chr(1), 1)
For i = 1 To CountString(temp$, Chr(1))+1
  Debug StringField(temp$, i, Chr(1))
Next i
End
Anthony Jordan
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: StringField to support string delimeter

Post by Foz »

+1...

But with the advent of regular expressions built into PB, it kinda becomes a moot point... though of course it would be a heck of a lot faster than regex look behinds and look aheads.
Post Reply