How to get the index of the first digit from a string in Node.js

1 Answer

0 votes
const str = 'javascript python 340 typescript 981 node.js';

const index = str.search(/[0-9]/);

console.log(index); 

  
  
  
  
/*
run:
  
18
  
*/

 



answered Jun 13, 2022 by avibootz
...