当前位置:网站首页>JS of learning notes -- split(), replace(), join()
JS of learning notes -- split(), replace(), join()
2022-06-28 06:23:00 【VIXeH】
Recently used split() This function , Suddenly, it feels very convenient
string.split(separator,limit)
Parameters 1: Optional . String or regular expression , Split from where specified by this parameter string Object.
Parameters 2: Optional . This parameter specifies the maximum length of the returned array . If this parameter is set , No more substrings will be returned than the array specified by this parameter . If the parameter is not set , The entire string will be split , Regardless of its length .
Returns an array of strings .
Take a chestnut :
Break this sentence down into words one by one ,
var str="How are you doing today?";
In this case, a space can be passed in ,
var n=str.split(" ");
n That's what it looks like :
n=[ 'How' , 'are' , 'you' , 'doing' , 'today?' ]
replace() Method is used to replace some characters with others in a string , Or replace a substring that matches a regular expression .
string.replace(searchvalue,newvalue)
Parameters 1: Mandatory , Replaced string
Parameters 2: Mandatory , Replace string
join() Method is used to convert all elements in the array into a string .
The elements are separated by the specified separator .
array.join(separator)
Parameters can be chosen . Specifies the separator to use . If this parameter is omitted , Then use comma as separator .
边栏推荐
猜你喜欢

AutoCAD C polyline small acute angle detection

Linked list (II) - Design linked list

Ethereum Classic的难度计算|猿创征文

Socket. Io long Connection Push, version Control, Real - Time Active user volume Statistics

mac下安装多个版本php并且进行管理

Alert pop-up processing in Web Automation

Openharmony gnawing paper growth plan -- json-rpc

cocoapod中的第三方库怎么引用本地头文件

MySQL (I) - Installation

Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
随机推荐
CAD二次开发+NetTopologySuite+PGIS 引用多版本DLL问题
The length of pytorch dataloader the difference between epoch and iteration
Install and manage multiple versions of PHP under mac
ImportError: cannot import name 'ensure_ dir_ Possible solutions for exists'
Linked list (II) - Design linked list
Oracle condition, circular statement
Xcode13.3.1 error reported after pod install
ThreadLocal
Exception handling (I) -- null pointer and array index out of bounds
助力涨点 | YOLOv5结合Alpha-IoU
idea创建类时自动添加注释
FPGA - 7系列 FPGA SelectIO -08- 高级逻辑资源之OSERDESE2
报错--解决core-js/modules/es.error.cause.js报错
AutoCAD C # Polyline Small Sharp angle Detection
JSP
Slow content advertising: the long-term principle of brand growth
Differences between overloads, rewrites, abstract classes and interfaces
MySQL(二)——基本操作
AutoCAD C# 多段線小銳角檢測
Example of MVVM framework based on kotlin+jetpack