Skip to content

Instantly share code, notes, and snippets.

@Chryus
Last active January 4, 2016 12:49
Show Gist options
  • Save Chryus/8624122 to your computer and use it in GitHub Desktop.
Save Chryus/8624122 to your computer and use it in GitHub Desktop.
> var reg = /([a-zA-Z\s]+) ([A-Z]{2})/
> var string = "New York NY 10006 United States"
> var res = string.match(reg);
> console.log(res);
[ 'New York NY',
'New York',
'NY',
index: 0,
input: 'New York NY 10006 United States' ]
> res.length
3
> res[0]
'New York NY'
> res[1]
'New York'
> res[2]
'NY'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment