How to replace the first matched number in a string using regex in JavaScript

1 Answer

0 votes
var s = "javascript01223c++3php500--9_8";

s = s.replace(/\d+/, "*");

document.write(s); 

 
 
  
/*
run:
   
javascript*c++3php500--9_8 
      
*/

 



answered Aug 3, 2019 by avibootz
...