当前位置:网站首页>JS written test -- regular expression
JS written test -- regular expression
2022-07-25 02:48:00 【H5_ ljy】
1. Remove the space before and after the string
var str=" hello "
var reg=/(^\s+)|(\s+$)/g
var re=str.replace(reg,"")
//var re=str.trim() A string of trim Can also be realized
console.log("a"+re+"x")
2. Determine whether the substring exists , If it exists, repeat times
var str="helloabc"
var reg=/l/g
var re=str.match(reg)//null Or array
if(re!==null){
console.log(" There is , repeated "+re.length+" Time ")
}else{console.log(" non-existent ")}

边栏推荐
- Flume's study notes
- Conceptual distinction between Po, Bo, VO, dto and POJO
- Go common standard library -time
- Remote sensing image classification tool and visualization application of WebGIS
- Summary and sorting of XSS (cross site script attack) related content
- Arduino + si5351 square wave generator
- Ctfshow misc introduction
- Redux best practices "Redux toolkit"
- Inheritance (prototype)
- [pyGame practice] nostalgic classic - do you remember the name of this chess game for children? (must collect)
猜你喜欢

Read and upgrade st-link chip information and SWD burning media through STM32 stlink utility tool

How to take the mold for the picture of 1.54 inch TFT st7789 LCD screen
![[system design] distributed key value database](/img/57/4d835d83f0e6ffb87e8ba39ec3b482.png)
[system design] distributed key value database
![[jailhouse article] scheduling policies and system software architectures for mixed criticality](/img/cc/874f8436991fdeb3a0e87e526c1753.png)
[jailhouse article] scheduling policies and system software architectures for mixed criticality

SQL Server 2022 installation

Arduino IDE for raspberry PI Pico development firmware localization installation tutorial

Keil compile download error: no algorithm found for: 08000000h - 08001233h solution

Object.defineproperty use

C: wechat chat software instance (wpf+websocket+webapi+entityframework)

Do you know about real-time 3D rendering? Real time rendering software and application scenarios are coming
随机推荐
After working for two months in the summer vacation, I understood three routing schemes of keepalived high availability
Cookies and sessions
Go multiplexing
B2B e-commerce trading platform of heavy metal industry: breaking the state of data isolation and improving the benefits of heavy metal industry
After six years of precipitation, new consumption has found a digital transformation paradigm
Wechat sports field reservation of the finished works of the applet graduation project (5) assignment
Strategy mode, just read one article
Project management tool Zen
Case analysis of building exhibition service management system with low code development platform
R language one page and many pictures
It7259q-13, it7259ex-24 feature wearable devices
Consul cluster deployment
Summary and sorting of XSS (cross site script attack) related content
YuQue - a useful tool for document writing and knowledge precipitation
File file name change
Domain driven model (DDD)
Wechat sports field reservation of applet completion works applet graduation design (8) graduation design thesis template
Arduino + si5351 square wave generator
Is redis'module'not an internal or external command?
Daily three questions 7.15