Skip to content

Instantly share code, notes, and snippets.

@ncammarata
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save ncammarata/0902a4a13e8a26c6ee12 to your computer and use it in GitHub Desktop.

Select an option

Save ncammarata/0902a4a13e8a26c6ee12 to your computer and use it in GitHub Desktop.
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