当前位置:网站首页>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 .
边栏推荐
- Linked list (II) - Design linked list
- ROS rviz_ Satellite function package visualizes GNSS track and uses satellite map
- JQ picture amplifier
- Simple handwritten debounce function
- Xcode13.3.1 error reported after pod install
- No one can only use foreach to traverse arrays, right?
- JDBC learning (I) -- implementing simple CRUD operations
- OpenSCAP 简介
- 手把手教你用Ucos
- Sklearn Feature Engineering (summary)
猜你喜欢

The custom cube UI pop-up dialog supports multiple and multiple types of input boxes

Xcode13.3.1 error reported after pod install

基于Kotlin+JetPack实现的MVVM框架的示例

Freeswitch使用originate转dialplan

ES9023音频解码芯片的工作原理

How popular are FB and WhatsApp mass messages in 2022?

Promotion intégrale et ordre des octets de fin de taille

How to add live chat in your Shopify store?

链表(二)——设计链表

Common basic functions of Oracle
随机推荐
Ethereum Classic的难度计算|猿创征文
Configure multiple database connections using the SSM framework
Yolact++ pytoch environment
AutoCAD C# 多段線小銳角檢測
[staff] arpeggio mark
Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
No one can only use foreach to traverse arrays, right?
JSP
death_satan/hyperf-validate
Pre training model parameter mismatch
AutoCAD C # Polyline Small Sharp angle Detection
职场IT老鸟的几点小习惯
Linked list (III) - reverse linked list
MR-WordCount
Caused by: com. fasterxml. jackson. databind. Exc.invalidformatexception: exception resolution
MySQL (II) - basic operation
Deep learning 19 loss functions
Enum
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance
Object对象转 List集合