Created
July 7, 2020 20:14
-
-
Save ondrej-kvasnovsky/752bcaf2423c57221790a0cd3b9793d2 to your computer and use it in GitHub Desktop.
JavaScript get Regex groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const input = 'hi:ha:ho'; | |
const matches = input.match(/(.*):(.*):(.*)/); | |
const firstGroup = matches[1]; | |
const secondGroup = matches[2]; | |
const thirdGroup = matches[3]; | |
console.log(firstGroup, secondGroup, thirdGroup); | |
// prints out: hi ha ho |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment