[Gambas-user] bug in function split?

Rob sourceforge-raindog2 at ...94...
Tue Apr 6 22:56:28 CEST 2004


On Tuesday 06 April 2004 13:55, Frank Berg wrote:
> that what i will say is that the split command is to split an
> formattet string back to the words..
> frank++++berg++++++flensburg
> benoit+++minisini+++++world

I would counter that "split" is meant to split a string on a 
separator character, whether there are words or not.  Consider 
the following VERY common situation, a CSV type file:

Minisini,Benoit,Mr.,575 Rue de Gambas,Paris,,FR,012345
Kudla,Rob,,108 Gambas Blvd,New York,NY,US,10110
Berg,Frank,,,,,,,

In the first row, the sixth field comes in as an empty string, as 
it should, and in the second row the third string comes in empty 
but the sixth string has a value.  In the last row, we have no 
data at all except the name but we should still get 8 fields, 
even though the last 6 are blanks.

I think making split use some kind of regular expression (as in, 
dare I say it, Perl) would be helpful, but I'm pretty okay with 
the way it works right now.  I mean, you can always 
Replace(string, "++", "+") before doing the split.

Rob





More information about the User mailing list