Created
July 24, 2018 13:34
-
-
Save smitroshin/5313b4cc0cb6bb8246786db944d5173e to your computer and use it in GitHub Desktop.
Get array with numbers from string
This file contains 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
function getNumFromString(string) { | |
const numbers = string.match(/\d+/g).map(Number); | |
return numbers; | |
} | |
export default getNumFromString; | |
// string = "border-radius:10px 20px 30px 40px" | |
// console.warn(getNumFromString(string)); | |
// Output: [10, 20, 30, 40] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment