Bizarre: string.split() method - DOTNET

This is a discussion on Bizarre: string.split() method - DOTNET ; This is too weird. You're going to love this one. I just ran across the most bizarre DotNet "feature" with the String.Split() method. You are supposed to pass it an array of characters to tell it what separators to split ...

+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 31

Bizarre: string.split() method

  1. Default Bizarre: string.split() method

    This is too weird. You're going to love this one.

    I just ran across the most bizarre DotNet "feature" with the String.Split()
    method. You are supposed to pass it an array of characters to tell it what
    separators to split the string on. if it finds any of those characters, it
    treats that as a separator.

    Well, in VB.NET you can turn off option strict if you want to write
    non-typesafe code (*bleh!*). This allows you to specify a string of
    characters instead of a character array, and it treats the entire string as
    a separator. Kind of handy, but I can find no way to do that in a typesafe
    language (you'd have to write your own function to split the string).



  2. Default Re: Bizarre: string.split() method


    Use Regex.Split() instead.

    -Oleg.

    "JV" <johnNOSPAMme@goisc.com> wrote in message
    news:ezCEzfRcFHA.3328@TK2MSFTNGP09.phx.gbl...
    > This is too weird. You're going to love this one.
    >
    > I just ran across the most bizarre DotNet "feature" with the

    String.Split()
    > method. You are supposed to pass it an array of characters to tell it

    what
    > separators to split the string on. if it finds any of those characters,

    it
    > treats that as a separator.
    >
    > Well, in VB.NET you can turn off option strict if you want to write
    > non-typesafe code (*bleh!*). This allows you to specify a string of
    > characters instead of a character array, and it treats the entire string

    as
    > a separator. Kind of handy, but I can find no way to do that in a

    typesafe
    > language (you'd have to write your own function to split the string).
    >
    >




  3. Default Re: Bizarre: string.split() method


    >Well, in VB.NET you can turn off option strict if you want to write
    >non-typesafe code (*bleh!*). This allows you to specify a string of
    >characters instead of a character array, and it treats the entire string as
    >a separator. Kind of handy, but I can find no way to do that in a typesafe
    >language (you'd have to write your own function to split the string).


    Can't you use String.ToCharArray() ?




    Mattias

    --
    Mattias Sjögren [MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

  4. Default Re: Bizarre: string.split() method

    well, vb doesn't use the String.Split, it has it own which you can call from
    the language of your choice.

    c#

    string[] r =
    Microsoft.VisualBasic.String.Split("string1**string2**string3","**");

    -- bruce (sqlwork.com)


    "JV" <johnNOSPAMme@goisc.com> wrote in message
    news:ezCEzfRcFHA.3328@TK2MSFTNGP09.phx.gbl...
    > This is too weird. You're going to love this one.
    >
    > I just ran across the most bizarre DotNet "feature" with the
    > String.Split() method. You are supposed to pass it an array of
    > characters to tell it what separators to split the string on. if it finds
    > any of those characters, it treats that as a separator.
    >
    > Well, in VB.NET you can turn off option strict if you want to write
    > non-typesafe code (*bleh!*). This allows you to specify a string of
    > characters instead of a character array, and it treats the entire string
    > as a separator. Kind of handy, but I can find no way to do that in a
    > typesafe language (you'd have to write your own function to split the
    > string).
    >




  5. Default Re: Bizarre: string.split() method

    Mattias Sjögren wrote:
    >>Well, in VB.NET you can turn off option strict if you want to write
    >>non-typesafe code (*bleh!*). This allows you to specify a string of
    >>characters instead of a character array, and it treats the entire string as
    >>a separator. Kind of handy, but I can find no way to do that in a typesafe
    >>language (you'd have to write your own function to split the string).

    >
    >
    > Can't you use String.ToCharArray() ?
    >
    >
    >
    >
    > Mattias
    >


    Yes you can!

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET

  6. Default Re: Bizarre: string.split() method

    But the origional poster says "it treats the entire string as a separator".
    Split a string using "as" as seperator will certainly not behave the same as
    using 'a' and 's'...

    "Mattias Sjogren" <mattias.dont.want.spam@mvps.org>
    ???????:em2REkRcFHA.720@TK2MSFTNGP15.phx.gbl...
    >
    >>Well, in VB.NET you can turn off option strict if you want to write
    >>non-typesafe code (*bleh!*). This allows you to specify a string of
    >>characters instead of a character array, and it treats the entire string
    >>as
    >>a separator. Kind of handy, but I can find no way to do that in a
    >>typesafe
    >>language (you'd have to write your own function to split the string).

    >
    > Can't you use String.ToCharArray() ?
    >
    >
    >
    >
    > Mattias
    >
    > --
    > Mattias Sjögren [MVP] mattias @ mvps.org
    > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    > Please reply only to the newsgroup.




  7. Default Re: Bizarre: string.split() method

    uh?
    what about (in 2.0 doc, I am not sure about 1.x)
    public string[] Split(
    string[] separator,
    StringSplitOptions options
    );

    "JV" <johnNOSPAMme@goisc.com> wrote in message
    news:ezCEzfRcFHA.3328@TK2MSFTNGP09.phx.gbl...
    > This is too weird. You're going to love this one.
    >
    > I just ran across the most bizarre DotNet "feature" with the
    > String.Split() method. You are supposed to pass it an array of
    > characters to tell it what separators to split the string on. if it finds
    > any of those characters, it treats that as a separator.
    >
    > Well, in VB.NET you can turn off option strict if you want to write
    > non-typesafe code (*bleh!*). This allows you to specify a string of
    > characters instead of a character array, and it treats the entire string
    > as a separator. Kind of handy, but I can find no way to do that in a
    > typesafe language (you'd have to write your own function to split the
    > string).
    >




  8. Default Re: Bizarre: string.split() method

    That is good to know. However, I think that requires loading that whole vb
    dll and any supportive dlls. That is probabably is a pretty big cost for
    one split function. Don't know the mem or perf cost as have not looked into
    it, but something to think about. Naturally, the same can be done pretty
    easy with a static regex method put in your utils library.

    --
    William Stacey [MVP]

    "Bruce Barker" <brubar_nospamplease_@safeco.com> wrote in message
    news:uFRODoRcFHA.2424@TK2MSFTNGP09.phx.gbl...
    > well, vb doesn't use the String.Split, it has it own which you can call
    > from the language of your choice.
    >
    > c#
    >
    > string[] r =
    > Microsoft.VisualBasic.String.Split("string1**string2**string3","**");
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "JV" <johnNOSPAMme@goisc.com> wrote in message
    > news:ezCEzfRcFHA.3328@TK2MSFTNGP09.phx.gbl...
    >> This is too weird. You're going to love this one.
    >>
    >> I just ran across the most bizarre DotNet "feature" with the
    >> String.Split() method. You are supposed to pass it an array of
    >> characters to tell it what separators to split the string on. if it
    >> finds any of those characters, it treats that as a separator.
    >>
    >> Well, in VB.NET you can turn off option strict if you want to write
    >> non-typesafe code (*bleh!*). This allows you to specify a string of
    >> characters instead of a character array, and it treats the entire string
    >> as a separator. Kind of handy, but I can find no way to do that in a
    >> typesafe language (you'd have to write your own function to split the
    >> string).
    >>

    >
    >




  9. Default Re: Bizarre: string.split() method

    JV wrote:
    > This is too weird. You're going to love this one.
    >
    > I just ran across the most bizarre DotNet "feature" with the String.Split()
    > method. You are supposed to pass it an array of characters to tell it what
    > separators to split the string on. if it finds any of those characters, it
    > treats that as a separator.
    >
    > Well, in VB.NET you can turn off option strict if you want to write
    > non-typesafe code (*bleh!*). This allows you to specify a string of
    > characters instead of a character array, and it treats the entire string as
    > a separator. Kind of handy, but I can find no way to do that in a typesafe
    > language (you'd have to write your own function to split the string).
    >
    >


    Time for you to learn c#

  10. Default Re: Bizarre: string.split() method

    Indeed this overload is new in 2.0... the 1.x Framework only has
    splitting on characters, not strings.

    On Wed, 15 Jun 2005 13:04:39 +1000, "Lloyd Dupont" <net.galador@ld>
    wrote:

    >uh?
    >what about (in 2.0 doc, I am not sure about 1.x)
    >public string[] Split(
    > string[] separator,
    > StringSplitOptions options
    >);

    --
    http://www.kynosarges.de

+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast

Similar Threads

  1. String.split() method question?
    By Application Development in forum Java
    Replies: 6
    Last Post: 12-17-2007, 08:49 PM
  2. how to use split method in ruby
    By Application Development in forum RUBY
    Replies: 5
    Last Post: 12-07-2007, 10:37 PM
  3. How to split string
    By Application Development in forum Python
    Replies: 7
    Last Post: 12-06-2007, 02:38 AM
  4. Replies: 1
    Last Post: 08-27-2007, 01:31 AM
  5. String.Split()
    By Application Development in forum DOTNET
    Replies: 2
    Last Post: 04-12-2007, 10:06 AM