← Back to challenges

RegEx Exercise 3: Find All Numbers

JavaScriptHardregex

Instructions

Write a RegExp that looks for all decimal numbers including integer ones, with the floating point and negative ones.

Example

const REGEXP = /your regexp/g

let str = "-1.5 0 2 -123.4."

str.match(REGEXP)  ➞ -1.5, 0, 2, -123.4

Notes

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Partially Hidden String