How js replace to replace the last occurrence of the string

When the regular expression greedy mode. * Will always match the last

// validate 
the let STR = "Hello World" ; 
the let RES = str.replace (/(.*) L /, '$ 10');    // $ + character after the replacement. 1 
the console.log (RES); // Hello wor0d

 

Guess you like

Origin www.cnblogs.com/weixuechao/p/12091139.html