Created
July 5, 2018 07:48
-
-
Save kitz99/874e948ab7fff92fbf0c5bb7d68901dc to your computer and use it in GitHub Desktop.
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 data = "This sentence uses word1 and also word2" | |
// using regex groups to extract word1 and word2 | |
var result = data.match(/^This sentence uses (.*) and also (.*)$/); | |
const opt1 = resutt[1]; | |
const opt2 = result[2]; | |
// using destructuring | |
const { 3: opt1, 6: opt2 } = data.split(' '); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment