JavaScript USES Replace for string substitution

  • 2020-05-27 04:26:07
  • OfStack

The example in this article shows how JavaScript USES Replace for string substitution. Share with you for your reference. The specific analysis is as follows:


var str='123123';
alert(str.replace('1','0')); // Only replace the first 1 The results for the 023123
alert(str.replace(/1/g,'0')); // Replace all the results with 023023

I hope this article has been helpful to your javascript programming.


Related articles: