[Gambas-user] Split Strings
Benoit Minisini
gambas at ...1...
Mon Jan 9 22:28:10 CET 2006
On Monday 09 January 2006 21:30, Rob Kudla wrote:
> On Mon January 9 2006 15:04, Mike Keehan wrote:
> > >>> IPADDR[0]="192.168.1.10"
> >
> > Split can take multiple separators. Try something like this:-
> > Bits = Split(s1, "[]=")
> > This produces four Message boxes on Gambas 1.0.13,
> > Maybe Benoit can tell us why the 3rd. one is blank :)
>
> It should be blank. Here are where the splits occur (sorry to
> people who don't use a fixed width font):
>
> IPADDR[0]="192.168.1.10"
> ^ ^^
>
> As you can see, there's nothing but an empty string between the
> second and third delimiters, so it puts an empty string in the
> array. Otherwise, it'd make parsing CSV files where there may
> or may not be a value for every field almost impossible, since
> you wouldn't know which field had been eliminated.
>
> Rob
>
Split(), in the development version, takes an extra boolean parameter that
tells him to remove void entries.
You can use also Scan(), this way:
PRINT Scan("IPADDR[0]=\"192.168.1.10\"", "IPADDR[*]=\"*\"").Join(";")
--> 0;192.168.1.10
Regards,
--
Benoit Minisini
More information about the User
mailing list