Hướng dẫn is there a split function in javascript? - có một chức năng tách trong javascript?

Phương thức

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
3 lấy một mẫu và chia
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
4 thành một danh sách các chuỗi con được đặt hàng bằng cách tìm kiếm mẫu, đặt các chuỗi con này vào một mảng và trả về mảng.
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
3
method takes a pattern and divides a
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
4 into an ordered list of substrings by searching for the pattern, puts these substrings into an array, and returns the array.

Thử nó

Cú pháp

split()
split(separator)
split(separator, limit)

Thông số

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 Tùy chọnOptional

Các mô hình mô tả nơi mỗi sự phân chia nên xảy ra. Có thể là một chuỗi hoặc một đối tượng có phương thức

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
6 - ví dụ điển hình là một biểu thức chính quy. Nếu không xác định, chuỗi mục tiêu ban đầu được trả về trong một mảng.

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
7 Tùy chọnOptional

Một số nguyên không âm chỉ định giới hạn về số lượng chuỗi con được đưa vào mảng. Nếu được cung cấp, hãy chia chuỗi ở mỗi lần xuất hiện của

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 được chỉ định, nhưng dừng khi các mục
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
7 đã được đặt trong mảng. Bất kỳ văn bản còn sót lại không được bao gồm trong mảng.

  • Mảng có thể chứa ít mục hơn so với
    "😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
    "😄😄".split(/(?:)/u); // [ "😄", "😄" ]
    
    7 nếu kết thúc của chuỗi đạt được trước khi đạt đến giới hạn.
  • Nếu
    "😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
    "😄😄".split(/(?:)/u); // [ "😄", "😄" ]
    
    7 là
    const emptyString = '';
    
    // string is empty and no separator is specified
    console.log(emptyString.split());
    // [""]
    
    // string and separator are both empty strings
    console.log(emptyString.split(emptyString));
    // []
    
    2,
    const emptyString = '';
    
    // string is empty and no separator is specified
    console.log(emptyString.split());
    // [""]
    
    // string and separator are both empty strings
    console.log(emptyString.split(emptyString));
    // []
    
    3 được trả về.

Giá trị trả về

Một

const emptyString = '';

// string is empty and no separator is specified
console.log(emptyString.split());
// [""]

// string and separator are both empty strings
console.log(emptyString.split(emptyString));
// []
4 của chuỗi, được chia tại mỗi điểm xảy ra
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 trong chuỗi đã cho.

Sự mô tả

Nếu

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 là một chuỗi không trống, chuỗi đích được phân chia bởi tất cả các trận đấu của
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 mà không bao gồm
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 trong kết quả. Ví dụ: một chuỗi chứa các giá trị phân tách (TSV) có thể được phân tích cú pháp bằng cách chuyển một ký tự tab dưới dạng dấu phân cách, như
const emptyString = '';

// string is empty and no separator is specified
console.log(emptyString.split());
// [""]

// string and separator are both empty strings
console.log(emptyString.split(emptyString));
// []
9. Nếu
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 chứa nhiều ký tự, toàn bộ chuỗi ký tự đó phải được tìm thấy để phân chia. Nếu
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 xuất hiện ở đầu (hoặc kết thúc) của chuỗi, nó vẫn có tác dụng phân tách, dẫn đến chuỗi trống (tức là độ dài bằng 0) xuất hiện ở vị trí đầu tiên (hoặc cuối cùng) của mảng được trả về. Nếu
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 không xảy ra trong
function splitString(stringToSplit, separator) {
  const arrayOfStrings = stringToSplit.split(separator)

  console.log('The original string is: ', stringToSplit)
  console.log('The separator is: ', separator)
  console.log('The array has ', arrayOfStrings.length, ' elements: ', arrayOfStrings.join(' / '))
}

const tempestString = 'Oh brave new world that has such people in it.'
const monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'

const space = ' '
const comma = ','

splitString(tempestString, space)
splitString(tempestString)
splitString(monthString, comma)
3, mảng được trả về chứa một phần tử bao gồm toàn bộ chuỗi.

Nếu

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 là một chuỗi trống (
function splitString(stringToSplit, separator) {
  const arrayOfStrings = stringToSplit.split(separator)

  console.log('The original string is: ', stringToSplit)
  console.log('The separator is: ', separator)
  console.log('The array has ', arrayOfStrings.length, ' elements: ', arrayOfStrings.join(' / '))
}

const tempestString = 'Oh brave new world that has such people in it.'
const monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'

const space = ' '
const comma = ','

splitString(tempestString, space)
splitString(tempestString)
splitString(monthString, comma)
5),
function splitString(stringToSplit, separator) {
  const arrayOfStrings = stringToSplit.split(separator)

  console.log('The original string is: ', stringToSplit)
  console.log('The separator is: ', separator)
  console.log('The array has ', arrayOfStrings.length, ' elements: ', arrayOfStrings.join(' / '))
}

const tempestString = 'Oh brave new world that has such people in it.'
const monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'

const space = ' '
const comma = ','

splitString(tempestString, space)
splitString(tempestString)
splitString(monthString, comma)
3 được chuyển đổi thành một mảng của mỗi "ký tự" UTF-16 của nó, mà không có chuỗi trống ở hai đầu của chuỗi kết quả.

Lưu ý: Do đó,

function splitString(stringToSplit, separator) {
  const arrayOfStrings = stringToSplit.split(separator)

  console.log('The original string is: ', stringToSplit)
  console.log('The separator is: ', separator)
  console.log('The array has ', arrayOfStrings.length, ' elements: ', arrayOfStrings.join(' / '))
}

const tempestString = 'Oh brave new world that has such people in it.'
const monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'

const space = ' '
const comma = ','

splitString(tempestString, space)
splitString(tempestString)
splitString(monthString, comma)
7 là cách duy nhất để tạo ra một mảng trống khi một chuỗi được truyền là
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5.
function splitString(stringToSplit, separator) {
  const arrayOfStrings = stringToSplit.split(separator)

  console.log('The original string is: ', stringToSplit)
  console.log('The separator is: ', separator)
  console.log('The array has ', arrayOfStrings.length, ' elements: ', arrayOfStrings.join(' / '))
}

const tempestString = 'Oh brave new world that has such people in it.'
const monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'

const space = ' '
const comma = ','

splitString(tempestString, space)
splitString(tempestString)
splitString(monthString, comma)
7 is therefore the only way to produce an empty array when a string is passed as
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5.

Nếu

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 là một regexp phù hợp với các chuỗi trống, liệu trận đấu có được chia bằng các đơn vị mã UTF-16 hay các codepoint Unicode phụ thuộc vào việc cờ
The original string is: "Oh brave new world that has such people in it."
The separator is: " "
The array has 10 elements: Oh / brave / new / world / that / has / such / people / in / it.

The original string is: "Oh brave new world that has such people in it."
The separator is: "undefined"
The array has 1 elements: Oh brave new world that has such people in it.

The original string is: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
The separator is: ","
The array has 12 elements: Jan / Feb / Mar / Apr / May / Jun / Jul / Aug / Sep / Oct / Nov / Dec
0 được đặt.

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]

Nếu

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 là biểu thức chính quy với các nhóm bắt giữ, thì mỗi lần
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 khớp, các nhóm bị bắt (bao gồm bất kỳ kết quả
The original string is: "Oh brave new world that has such people in it."
The separator is: " "
The array has 10 elements: Oh / brave / new / world / that / has / such / people / in / it.

The original string is: "Oh brave new world that has such people in it."
The separator is: "undefined"
The array has 1 elements: Oh brave new world that has such people in it.

The original string is: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
The separator is: ","
The array has 12 elements: Jan / Feb / Mar / Apr / May / Jun / Jul / Aug / Sep / Oct / Nov / Dec
3 nào) được ghép vào mảng đầu ra. Hành vi này được chỉ định bằng phương pháp
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
6 của RegEXP.

Nếu

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 là một đối tượng có phương thức
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
6, phương thức đó được gọi với chuỗi đích và
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
7 làm đối số và
The original string is: "Oh brave new world that has such people in it."
The separator is: " "
The array has 10 elements: Oh / brave / new / world / that / has / such / people / in / it.

The original string is: "Oh brave new world that has such people in it."
The separator is: "undefined"
The array has 1 elements: Oh brave new world that has such people in it.

The original string is: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
The separator is: ","
The array has 12 elements: Jan / Feb / Mar / Apr / May / Jun / Jul / Aug / Sep / Oct / Nov / Dec
8 được đặt thành đối tượng. Giá trị trả về của nó trở thành giá trị trả về của
The original string is: "Oh brave new world that has such people in it."
The separator is: " "
The array has 10 elements: Oh / brave / new / world / that / has / such / people / in / it.

The original string is: "Oh brave new world that has such people in it."
The separator is: "undefined"
The array has 1 elements: Oh brave new world that has such people in it.

The original string is: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
The separator is: ","
The array has 12 elements: Jan / Feb / Mar / Apr / May / Jun / Jul / Aug / Sep / Oct / Nov / Dec
9.

Bất kỳ giá trị nào khác sẽ được ép buộc vào một chuỗi trước khi được sử dụng làm dấu phân cách.

Ví dụ

Sử dụng Split ()

Khi chuỗi trống và không có dấu tách nào được chỉ định,

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
3 trả về một mảng chứa một chuỗi trống, thay vì một mảng trống. Nếu chuỗi và phân tách đều là các chuỗi trống, một mảng trống được trả về.

const emptyString = '';

// string is empty and no separator is specified
console.log(emptyString.split());
// [""]

// string and separator are both empty strings
console.log(emptyString.split(emptyString));
// []

Ví dụ sau đây xác định một hàm chia chuỗi thành một mảng các chuỗi bằng cách sử dụng

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5. Sau khi chia chuỗi, các thông báo nhật ký hàm chỉ ra chuỗi gốc (trước khi phân chia), bộ phân cách được sử dụng, số lượng phần tử trong mảng và các phần tử mảng riêng lẻ.

function splitString(stringToSplit, separator) {
  const arrayOfStrings = stringToSplit.split(separator)

  console.log('The original string is: ', stringToSplit)
  console.log('The separator is: ', separator)
  console.log('The array has ', arrayOfStrings.length, ' elements: ', arrayOfStrings.join(' / '))
}

const tempestString = 'Oh brave new world that has such people in it.'
const monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'

const space = ' '
const comma = ','

splitString(tempestString, space)
splitString(tempestString)
splitString(monthString, comma)

Ví dụ này tạo ra đầu ra sau:

The original string is: "Oh brave new world that has such people in it."
The separator is: " "
The array has 10 elements: Oh / brave / new / world / that / has / such / people / in / it.

The original string is: "Oh brave new world that has such people in it."
The separator is: "undefined"
The array has 1 elements: Oh brave new world that has such people in it.

The original string is: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
The separator is: ","
The array has 12 elements: Jan / Feb / Mar / Apr / May / Jun / Jul / Aug / Sep / Oct / Nov / Dec

Loại bỏ khoảng trắng khỏi chuỗi

Trong ví dụ sau,

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
3 tìm kiếm không gian hoặc nhiều không gian, theo sau là dấu chấm phẩy, theo sau là không có hoặc nhiều không gian hơn và khi tìm thấy, loại bỏ các không gian và dấu chấm phẩy khỏi chuỗi.
const names = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand '

console.log(names)

const re = /\s*(?:;|$)\s*/
const nameList = names.split(re)

console.log(nameList)
3 là mảng được trả về do
"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
3.

const names = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand '

console.log(names)

const re = /\s*(?:;|$)\s*/
const nameList = names.split(re)

console.log(nameList)

Điều này ghi lại hai dòng; Dòng đầu tiên ghi lại chuỗi ban đầu và dòng thứ hai ghi lại mảng kết quả.

Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand
[ "Harry Trump", "Fred Barney", "Helen Rigby", "Bill Abel", "Chris Hand", "" ]

Trả lại một số lượng hạn chế các phân tách

Trong ví dụ sau,

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
3 tìm khoảng trống trong một chuỗi và trả về 3 lần chia đầu tiên mà nó tìm thấy.

const myString = 'Hello World. How are you doing?'
const splits = myString.split(' ', 3)

console.log(splits)

Tập lệnh này hiển thị như sau:

["Hello", "World.", "How"]

Chia tách với const names = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand ' console.log(names) const re = /\s*(?:;|$)\s*/ const nameList = names.split(re) console.log(nameList) 6 để bao gồm các phần của dấu tách trong kết quả

Nếu

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
5 là một biểu thức chính quy chứa thu thập dấu ngoặc đơn
const names = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand '

console.log(names)

const re = /\s*(?:;|$)\s*/
const nameList = names.split(re)

console.log(nameList)
8
const names = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand '

console.log(names)

const re = /\s*(?:;|$)\s*/
const nameList = names.split(re)

console.log(nameList)
9, kết quả phù hợp được bao gồm trong mảng.

const myString = 'Hello 1 word. Sentence number 2.'
const splits = myString.split(/(\d)/)

console.log(splits)

Tập lệnh này hiển thị như sau:

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
0

Chia tách với

const names = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand '

console.log(names)

const re = /\s*(?:;|$)\s*/
const nameList = names.split(re)

console.log(nameList)
6 để bao gồm các phần của dấu tách trong kết quả
Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand
[ "Harry Trump", "Fred Barney", "Helen Rigby", "Bill Abel", "Chris Hand", "" ]
0 matches the character class for digits between 0 and 9.

Nếu "😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ] "😄😄".split(/(?:)/u); // [ "😄", "😄" ] 5 là một biểu thức chính quy chứa thu thập dấu ngoặc đơn const names = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand ' console.log(names) const re = /\s*(?:;|$)\s*/ const nameList = names.split(re) console.log(nameList) 8 const names = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand ' console.log(names) const re = /\s*(?:;|$)\s*/ const nameList = names.split(re) console.log(nameList) 9, kết quả phù hợp được bao gồm trong mảng.

Lưu ý:

Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand
[ "Harry Trump", "Fred Barney", "Helen Rigby", "Bill Abel", "Chris Hand", "" ]
0 khớp với lớp ký tự cho các chữ số từ 0 đến 9.

Sử dụng bộ chia tùy chỉnh

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
1

Ví dụ sau đây sử dụng trạng thái nội bộ để thực thi một số hành vi nhất định và để đảm bảo kết quả "hợp lệ" được tạo ra.

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
2

Thông số kỹ thuật

Sự chỉ rõ
Đặc tả ngôn ngữ Ecmascript # sec-string.prototype.split
# sec-string.prototype.split

Tính tương thích của trình duyệt web

Bảng BCD chỉ tải trong trình duyệt

Xem thêm

Làm thế nào để bạn chia một đối tượng trong JavaScript?

Phương thức Split () được sử dụng để chia một đối tượng chuỗi thành một mảng chuỗi bằng cách chia chuỗi thành chuỗi con. Dấu tách: ký tự để tách chuỗi. Bản thân dấu tách là một chuỗi. Nếu dấu phân cách không có mặt, nó sẽ trả về toàn bộ chuỗi. is used to split a string object into an array of strings by breaking the string into substrings. separator: The character to separate the string. The separator itself is a string. If the separator is not present it returns the entire string.

Làm thế nào để bạn chia và tham gia JavaScript?

Cách hoạt động: Đầu tiên, chia chuỗi tiêu đề cho không gian thành một mảng bằng cách sử dụng phương thức chuỗi chia ().Thứ ba, chuyển đổi chuỗi kết quả thành chữ thường bằng cách sử dụng phương thức tolowerCase ().split the title string by the space into an array by using the split() string method. Second, concatenate all elements in the result array into a string by using the join() method. Third, convert the result string to lower case by using the toLowerCase() method.

Chia tách () làm gì?

Phương thức chia () chia một chuỗi vào một danh sách.Bạn có thể chỉ định phân tách, dấu phân cách mặc định là bất kỳ khoảng trắng nào.Lưu ý: Khi MaxSplit được chỉ định, danh sách sẽ chứa số lượng phần tử được chỉ định cộng với một.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.

Hàm chia () trong chuỗi là gì?

Tách được sử dụng để chia một chuỗi được phân định thành chuỗi con.Bạn có thể sử dụng một mảng ký tự hoặc mảng chuỗi để chỉ định các ký tự hoặc chuỗi phân định hoặc nhiều hơn.Nếu không có ký tự phân định nào được chỉ định, chuỗi được phân chia tại các ký tự không gian trắng.used to break a delimited string into substrings. You can use either a character array or a string array to specify zero or more delimiting characters or strings. If no delimiting characters are specified, the string is split at white-space characters.