Skip to content

Instantly share code, notes, and snippets.

@espl-saket
Created January 5, 2016 06:50
Show Gist options
  • Save espl-saket/9dce833f7992e7cc3759 to your computer and use it in GitHub Desktop.
Save espl-saket/9dce833f7992e7cc3759 to your computer and use it in GitHub Desktop.
Regex to extract string and number from a combination of both
var stringPattern = /[A-Za-z]+/g;
var numberPattern = /\d+/g;
'This10Is200'.match(stringPattern);
// Returns ["This", "Is"]
'This10Is200'.match(numberPattern);
// Returns ["10", "200"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment