close
1.\b \B
this is a book
reg=\bis\b .replace ya =>this ya book
reg=\Bis\b .replace ya =>thya is book
2.
string=12345678
\d{3,5}
2.1貪婪模式
.replace ya =>ya678
2.2
\d{3,5}?
.replace ya =>yaya78
3.
a1b2c3d4.replace(/([a-z]\d){3}/,'X') =Xd4
3.1
'BryohCasper.replace(/Byron|Casper/,'x' = xx
4.日期
2015-12-25.replace(/(\d{4})-(\d{2})-()\d{2}/,$2/$3/$1)
12/25/2015
5.() 忽略分組
(:?abc) 就不是他$1
6.
前瞻
?=
?!
a2*34vv replace('/\w(?!\d)/g','X') aX*3XXX
a2*3.replace /\w(?=\d)/g,'X' X2*3
全站熱搜