Skip to content

Instantly share code, notes, and snippets.

@smitroshin
Created July 24, 2018 13:34
Show Gist options
  • Save smitroshin/5313b4cc0cb6bb8246786db944d5173e to your computer and use it in GitHub Desktop.
Save smitroshin/5313b4cc0cb6bb8246786db944d5173e to your computer and use it in GitHub Desktop.
Get array with numbers from string
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