How to extract all numbers from string in TypeScript

1 Answer

0 votes
const s = "typecript4php412hjdsf72q1p0on8mq php 9953";
  
const arr = s.match(/^\d+|\d+\b|\d+(?=\w)/g);
  
console.log(arr); 
  
    
      
      
/*
run:
      
["4", "412", "72", "1", "0", "8", "9953"]
      
*/

 



answered Jan 30, 2022 by avibootz
...