-4

how can I remove all non-numeric characters with a regex, leaving ab3f4 // => 34 (using javascript)

Aleksandr
  • 15
  • 3
  • 3
    What have you tried so far? Questions should show previous research. – sanitizedUser Jul 13 '20 at 16:35
  • 1
    Searching for this would have yielded multiple answers. That said: I'd recommend spending an hour going through some basic regex tutorials; regexes are one of the tools that should be in everyone's toolbox. Their importance cannot be overstated, across domains and ecosystems. (With the caveat that they're not the best solution for *every* task: when regexes are your hammer everything looks like a thumb.) – Dave Newton Jul 13 '20 at 16:37
  • 1
    [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/a/261593/3082296) – adiga Jul 13 '20 at 16:50

1 Answers1

-2

Just do .replace(/\D/g, ''):

console.log('ab3f4'.replace(/\D/g, ''))
dave
  • 62,300
  • 5
  • 72
  • 93
  • A downvote for a correct answer on a poor question, IMO, is an abuse of downvoting. YMMV. – Dave Newton Jul 13 '20 at 16:48
  • @DaveNewton while I agree, it doesn't really matter to me, I answer to be helpful not because I care about the points – dave Jul 13 '20 at 16:57