Skip to content

Instantly share code, notes, and snippets.

@sergiycheck
Created November 11, 2021 14:22
Show Gist options
  • Save sergiycheck/a1059c6422b10f00819b353f16846fa0 to your computer and use it in GitHub Desktop.
Save sergiycheck/a1059c6422b10f00819b353f16846fa0 to your computer and use it in GitHub Desktop.
find num in string
function findNumInString(str) {
const arrMatches = str.match(/\d+/g);
const num = Number(arrMatches[0]);
return num ? num : 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment