📌  相关文章
📜  .replace( g '') - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:06.292000             🧑  作者: Mango

代码示例1
//Replace the first lowercase t we find with X
'This is sparta!'.replace(/t/,'X');
//result: 'This is sparXa!'

//Replace the first letter t (upper or lower) with X
'This is sparta!'.replace(/t/i, 'X');
//result: 'Xhis is sparta!'

//Replace all the Ts in the text (upper or lower) with X
'This is sparta!'.replace(/t/gi, 'X' );
//result: 'Xhis is sparXa!'