In My case I am using react native typescript, I want to get only numbers from group string without comma. How to get it using regex match or replace?
taskname = TASK_XC0.0.0.0.89t_abc_test
let task = taskname.match( /[0-9]+/g, ''); //0,0,0,0,89
Actual output need to get 000089
let str = "TASK_XC0.0.0.0.89t_abc_test" console.log(str.replace(/[^0-9]/g,''))
use join method to remove comma
const taskName = 'TASK_XC0.0.0.0.89t_abc_test'
const task = taskName.match(/[0-9]+/g, '').join('');
output: 000089
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.