Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Split() without parameters, what is the default delimiter?

Tags:

c#

So I looked at the String.Split() method in C# today and I realized that you can pass it zero arguments as well which I never considered.

What is the default delimiter when you use Split() without any parameters?

like image 920
OmniOwl Avatar asked May 02 '16 07:05

OmniOwl


People also ask

What is the default delimiter in split ()?

The split() method splits a string into a list. You can specify the separator, default separator is any whitespace. Note: When maxsplit is specified, the list will contain the specified number of elements plus one.

How do you split data by delimiter in Python?

Splitting the String Based on Multiple Delimiters:Multiple delimiters can be specified as a parameter to the split() function by separating each delimiter with a |. The given string or line with multiple delimiters is separated using a split function called re. split() function.

What does the split () method return from a list of words?

Description. Python string method split() returns a list of all the words in the string, using str as the separator (splits on all whitespace if left unspecified), optionally limiting the number of splits to num.


3 Answers

In case of no values it's white space - source from here:

If the separator argument is null or contains no characters, the method treats white-space characters as the delimiters. White-space characters are defined by the Unicode standard; they return true if they are passed to the Char.IsWhiteSpace method.

like image 63
fubo Avatar answered Sep 18 '22 07:09

fubo


If you look at the source, you can see that if you're passing null or an empty array (default for a params parameter if you omit the argument), it's using Char.IsWhiteSpace to check if the string contains whitespace characters and adds them to the list of separators.

ProTip! Next time you're wondering what a framework method does, check out the source at sourceof.net.

like image 29
khellang Avatar answered Sep 18 '22 07:09

khellang


The default is whitespace - but to add upon the other answers, this includes \n newline characters.

like image 25
Dylanh-pt Avatar answered Sep 21 '22 07:09

Dylanh-pt