Last active
August 29, 2015 14:06
-
-
Save ncammarata/0902a4a13e8a26c6ee12 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| str = "hello [nick] youre a baler [coder] and u [hot] how is this [possible]" | |
| strings = [] // this is an array of all the results | |
| newStr = '' // this is the current string we're keeping | |
| foundLeft = false // are we in a bracket | |
| for i in str | |
| if (i is '[') foundLeft = true | |
| if (i is ']') { | |
| foundLeft = false | |
| strings.push(newStr) | |
| newString = '' | |
| } | |
| if (foundLeft) newStr += i | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment