Getting signed or unsigned numbers from string "0px -123px".match(/-?\d+/g) Results: 0 123px => [0, 123] -0px -123px => [-0, -123]