how to extract numbers from the string in typescript?
Extract number from string in typescript To extract a number from a string in typescript, use the match() method with the /\d+/g regex it will find all numbers from the string and return as an array of numbers. const REGEX = /\d+/g; let sampleString: string = "#div-name-1234-characteristic:561613213213"; let arrOfNumber: Array<number> = sampleString.match(REGEX); // 👇️ [ '1234', '561613213213' ] console.log(arrOfNumber) Today, I’m going to show you How to i extract a number from a string in typescript, as mentioned above, I’m going to use the use match() and join() method with /\d+/g regex to extract numbers from string and convert in digits....