Skip to content

Instantly share code, notes, and snippets.

@ashwinkumar2438
Created August 31, 2020 17:04
Show Gist options
  • Save ashwinkumar2438/21c8d4e5b6c7c9082d72e5b5fd8fa2db to your computer and use it in GitHub Desktop.
Save ashwinkumar2438/21c8d4e5b6c7c9082d72e5b5fd8fa2db to your computer and use it in GitHub Desktop.
var regex=/(?<circle>\d{2})(?<district>\d)[\s-]?(?<office>\d{3})/;
console.log(regex.exec("412207").groups); //{circle: "41", district: "2", office: "207"}
console.log(regex.exec("182-101").groups); //{circle: "18", district: "2", office: "101"}
console.log(regex.exec("224 123").groups); //{circle: "22", district: "4", office: "123"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment