-2
myArray = ['1 in','2 in', '3 in']

expected output=

['1','2','3']

but if we add we should able to type ","

I have tried trim, split, paresfloat, filter methods but it's not working.

adiga
  • 34,372
  • 9
  • 61
  • 83

1 Answers1

0

Try this solution

let arr = ["1 in" , "2 in", "3 in"]
let filteredArray = arr.map((elt)=>elt.replace( /(?!-)[^0-9.]/g, ""))
console.log(filteredArray)
Khaled Ayed
  • 1,121
  • 3
  • 12
  • 29