Created
October 13, 2020 03:50
-
-
Save trevsm/802ac37ee1d9592f15d1d7cb30c990b0 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
// returns array with existing delimiters | |
function parseText(text){ | |
const reg1 = /(?<=\[name\]|\[age\])/g // negative lookahead | |
const reg2 = /(?=\[name\]|\[age\])/g // positive lookahead | |
return(Array.prototype.concat.apply([], (text.split(reg1).map(m => m.split(reg2))))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment