MS: String.Split is missing an IMPORTANT overload (IMO) 
Author Message
 MS: String.Split is missing an IMPORTANT overload (IMO)

Hi,

In case some MS-VB.NET guys are lurking around, might I suggest that there
is another Split overload that could be a BIG help (or it's there, I can't
find it).  An overload of Split should only return substrings that are
separated by 1 or more of the delimiting characters.  In fact that is the
way that the documentation reads ("Returns an array of substrings that are
delimited by one or more of the characters in 'separator' " [paraphased]).
BUT, as in the VB6 version, Split returns 1-more array elements with a value
of null if there is more than one delimiting character.  This makes for a
bunch of additional logic in order to separate the "good" data from the
nulls.

One of the uses for the Split method is to parse text.  I want to parse on
1-more white spaces and NOT get a bunch of null array entries mingled in
with the good stuff.

For VB 6 I ended up writing my own function.  I had hoped that VB.NET would
take care of the problem.  And, of course, overloading Split is out of the
question since String is immutable.

Have I missed something?

Larry Woods



Mon, 06 Dec 2004 04:43:56 GMT  
 MS: String.Split is missing an IMPORTANT overload (IMO)
You should use regular expressions.


Quote:
> Hi,

> In case some MS-VB.NET guys are lurking around, might I suggest that there
> is another Split overload that could be a BIG help (or it's there, I can't
> find it).  An overload of Split should only return substrings that are
> separated by 1 or more of the delimiting characters.  In fact that is the
> way that the documentation reads ("Returns an array of substrings that are
> delimited by one or more of the characters in 'separator' " [paraphased]).
> BUT, as in the VB6 version, Split returns 1-more array elements with a
value
> of null if there is more than one delimiting character.  This makes for a
> bunch of additional logic in order to separate the "good" data from the
> nulls.

> One of the uses for the Split method is to parse text.  I want to parse on
> 1-more white spaces and NOT get a bunch of null array entries mingled in
> with the good stuff.

> For VB 6 I ended up writing my own function.  I had hoped that VB.NET
would
> take care of the problem.  And, of course, overloading Split is out of the
> question since String is immutable.

> Have I missed something?

> Larry Woods



Mon, 06 Dec 2004 04:51:09 GMT  
 MS: String.Split is missing an IMPORTANT overload (IMO)
Possible solution, but a bit of overkill, don't you think?


Quote:
> You should use regular expressions.



> > Hi,

> > In case some MS-VB.NET guys are lurking around, might I suggest that
there
> > is another Split overload that could be a BIG help (or it's there, I
can't
> > find it).  An overload of Split should only return substrings that are
> > separated by 1 or more of the delimiting characters.  In fact that is
the
> > way that the documentation reads ("Returns an array of substrings that
are
> > delimited by one or more of the characters in 'separator' "
[paraphased]).
> > BUT, as in the VB6 version, Split returns 1-more array elements with a
> value
> > of null if there is more than one delimiting character.  This makes for
a
> > bunch of additional logic in order to separate the "good" data from the
> > nulls.

> > One of the uses for the Split method is to parse text.  I want to parse
on
> > 1-more white spaces and NOT get a bunch of null array entries mingled in
> > with the good stuff.

> > For VB 6 I ended up writing my own function.  I had hoped that VB.NET
> would
> > take care of the problem.  And, of course, overloading Split is out of
the
> > question since String is immutable.

> > Have I missed something?

> > Larry Woods



Mon, 06 Dec 2004 07:59:02 GMT  
 MS: String.Split is missing an IMPORTANT overload (IMO)
Definately can't inherit from string.  There are times, such as with comma
delimited lists when two commas in a row should generate a null entry.

I agree that it would take longer to figure out how to do it regex that it
would to write a compress function that would prepare the string for split.
Something like...

Compress(s as string, seperator as char) as string

which would compress all multiples of seperator to a single seperator char.
Then

stringArray = Compress(theString, " ").split(nothing)


Quote:
> Hi,

> In case some MS-VB.NET guys are lurking around, might I suggest that there
> is another Split overload that could be a BIG help (or it's there, I can't
> find it).  An overload of Split should only return substrings that are
> separated by 1 or more of the delimiting characters.  In fact that is the
> way that the documentation reads ("Returns an array of substrings that are
> delimited by one or more of the characters in 'separator' " [paraphased]).
> BUT, as in the VB6 version, Split returns 1-more array elements with a
value
> of null if there is more than one delimiting character.  This makes for a
> bunch of additional logic in order to separate the "good" data from the
> nulls.

> One of the uses for the Split method is to parse text.  I want to parse on
> 1-more white spaces and NOT get a bunch of null array entries mingled in
> with the good stuff.

> For VB 6 I ended up writing my own function.  I had hoped that VB.NET
would
> take care of the problem.  And, of course, overloading Split is out of the
> question since String is immutable.

> Have I missed something?

> Larry Woods



Mon, 06 Dec 2004 14:51:07 GMT  
 MS: String.Split is missing an IMPORTANT overload (IMO)
Larry:

Good suggestion. We'll consider this for a future version. Thanks!

Paul Vick [MSFT]

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Hi,

> In case some MS-VB.NET guys are lurking around, might I suggest that there
> is another Split overload that could be a BIG help (or it's there, I can't
> find it).  An overload of Split should only return substrings that are
> separated by 1 or more of the delimiting characters.  In fact that is the
> way that the documentation reads ("Returns an array of substrings that are
> delimited by one or more of the characters in 'separator' " [paraphased]).
> BUT, as in the VB6 version, Split returns 1-more array elements with a
value
> of null if there is more than one delimiting character.  This makes for a
> bunch of additional logic in order to separate the "good" data from the
> nulls.

> One of the uses for the Split method is to parse text.  I want to parse on
> 1-more white spaces and NOT get a bunch of null array entries mingled in
> with the good stuff.

> For VB 6 I ended up writing my own function.  I had hoped that VB.NET
would
> take care of the problem.  And, of course, overloading Split is out of the
> question since String is immutable.

> Have I missed something?

> Larry Woods



Sat, 11 Dec 2004 03:41:17 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Best way to split string - mid() or split()?

2. how to split a split string

3. Not very important, but I am curious

4. Hey MS, how about deprecating Overloads and NotOverridable?

5. Somebody tell me, can MS Winsock control overload???

6. IMPORTANT HELP for MS MAPI Controls!

7. IMPORTANT HELP for MS MAPI Controls

8. Access Runtime - Am I Missing Something?

9. AM I missing something - Sum and Cumulative Sum

10. What am I missing?

11. What am I missing in this error handler?

12. What Am I Missing?

 

 
Powered by phpBB® Forum Software