Hướng dẫn what is split in html? - phân chia trong html là gì?


Tìm hiểu cách tạo màn hình chia (50/50) với CSS.

Show

Hãy tự mình thử »


Cách tạo màn hình chia

Bước 1) Thêm HTML:

Thí dụ

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; Jane Flex & nbsp; & nbsp; & nbsp; Một số văn bản. & Nbsp;
 


   
Hướng dẫn what is split in html? - phân chia trong html là gì?

   

Jane Flex


   

Some text.


 

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; John Doe & nbsp; & nbsp; & nbsp; Một số văn bản ở đây quá. & Nbsp;
 


   
Hướng dẫn what is split in html? - phân chia trong html là gì?

   

John Doe


   

Some text here too.


 



Bước 2) Thêm CSS:

Thí dụ

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; Jane Flex & nbsp; & nbsp; & nbsp; Một số văn bản. & Nbsp;
.split {
  height: 100%;
  width: 50%;
  position: fixed;
  z-index: 1;
  top: 0;
  overflow-x: hidden;
  padding-top: 20px;
}

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; John Doe & nbsp; & nbsp; & nbsp; Một số văn bản ở đây quá. & Nbsp;
.left {
  left: 0;
  background-color: #111;
}

Bước 2) Thêm CSS:
.right {
  right: 0;
  background-color: red;
}

/ * Chia màn hình trong một nửa */. Split {& nbsp; Chiều cao: 100%; & nbsp; chiều rộng: 50%; & nbsp; Vị trí: Đã sửa; & nbsp; Z-index: 1; & nbsp; Top: 0; & nbsp; Overflow-x: ẩn; & nbsp; Padding-Top: 20px;}
.centered {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

/ * Kiểm soát phía bên trái */. Trái {& nbsp; trái: 0; & nbsp; màu nền: #111;}
.centered img {
  width: 150px;
  border-radius: 50%;
}

Hãy tự mình thử »



Những gì được chia trong 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.

Phương thức chia () lấy một mẫu và chia một chuỗi 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.

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()
split(separator)
split(separator, limit)

Thử nó

Cú phápOptional

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.

  • 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

Một đối tượng có phương thức

"😄😄".split(/(?:)/); // [ "\ud83d", "\ude04", "\ud83d", "\ude04" ]
"😄😄".split(/(?:)/u); // [ "😄", "😄" ]
6 có thể được sử dụng như một bộ chia với hành vi tùy chỉnh.

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

Ví dụ sau đây phân tách một chuỗi bằng trạng thái bên trong bao gồm số tăng:

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.
Thông số kỹ thuật
# sec-string.prototype.split

Sự chỉ rõ

Đặc tả ngôn ngữ Ecmascript # sec-string.prototype.split

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

Việc sử dụng Split () là gì?

Hàm chia () có thể được sử dụng để phân chia một chuỗi đã cho hoặc một dòng bằng cách chỉ định một trong các chuỗi con của chuỗi đã cho là dấu phân cách.Chuỗi trước và sau khi chuỗi con được chỉ định là dấu phân cách được trả về dưới dạng đầu ra.to split a given string or a line by specifying one of the substrings of the given string as the delimiter. The string before and after the substring specified as a delimiter is returned as the output.

Bộ phận phân chia trong mã là gì?

Tách mã là sự phân chia mã thành các gói hoặc thành phần khác nhau sau đó có thể được tải theo yêu cầu hoặc song song.Khi một ứng dụng phát triển về độ phức tạp hoặc được duy trì, các tệp hoặc gói JavaScripts phát triển theo kích thước byte, đặc biệt là khi số lượng và kích thước của các thư viện bên thứ ba bao gồm tăng lên.the splitting of code into various bundles or components which can then be loaded on demand or in parallel. As an application grows in complexity or is maintained, CSS and JavaScripts files or bundles grow in byte size, especially as the number and size of included third-party libraries increases.

Chúng ta có thể sử dụng Split trong HTML không?

Tôi sử dụng Split ("") cho khoảng trắng và sử dụng Split (/(]*>)/) cho thẻ HTML trong chuỗi.

Những gì được chia trong mảng?

Phương thức chia () lấy một mẫu và chia một chuỗi 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.divides a String into an ordered list of substrings by searching for the pattern, puts these substrings into an array, and returns the array.