Skip to content

Instantly share code, notes, and snippets.

@juanrules
Last active September 26, 2019 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanrules/7efcb8680af482a71ec8f1bf3b8c16e6 to your computer and use it in GitHub Desktop.
Save juanrules/7efcb8680af482a71ec8f1bf3b8c16e6 to your computer and use it in GitHub Desktop.
Useful Regex patterns
const fragment = 'hello:222';
const fragment = 'hello:222]';
// Get any number at the end of a string
const anyDigitsFromEndOFString = /\d+$/g;
console.log(fragment.match(anyDigitsFromEndOFString)); // ["222"]
console.log(fragment2.match(anyDigitsFromEndOFString)); // null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment