Last active
February 5, 2022 21:18
-
-
Save queviva/5e0ab15d96dcbf55bbb51e245c522b9a to your computer and use it in GitHub Desktop.
converts a string into an array of numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const toNumArray = s => s.match(/[\d\.-]+/g).map(p=>Number(p)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
uses a really quick and highly functional match to convert anything that resembles a number into an actual number
toNumArray('hsla(270,80%,40.25%,0.7)') //[270, 80, 40.25, 0.7]