[Question]
  [
**Task:**
Input will consist of some text, with nested `[]` separating some of it into nested groups:
```
abc[d[fgijk]nopq]rst[u[v[[w]]]xy[[[z]]]]
```
Your task is to remove all brackets, and everything wrapped in an odd number of brackets. For example, `a[b]c` would remove the `[]`, and the `b` inside of it. `a[[b]]c`, however, would only remove the brackets (as `b` is wrapped in an even number of brackets). If the string were instead `a[b[c]d]f`, the result would be `acf`, as the `b` and `d` are wrapped in an odd number of brackets, but `c` is not.
The correct output for the input given at the top would be:
```
abcfgijkrstvwz
```
**I/O:**
You can take input as a string, or any reasonable representation of one (like an array of characters). You can output in a similar fashion, with trailing whitespacing being allowed. You can assume all non-bracket characters are lowercase letters, and you can choose whether the brackets are `()`, `[]`, or `{}`.
You can assume the brackets are properly nested (e.g., `[` or `][` won't be given as inputs), and that there is at least one letter in the input.
**Test cases:**
```
abc                                                 abc
a[b]c                                               ac
[ab]c                                               c
ab[c]                                               ab
[]abc                                               abc
a[]bc                                               abc
abc[]                                               abc
a[[b]]c                                             abc
a[[[b]]]c                                           ac
a[b][c]d                                            ad
a[b][]c                                             ac
[a[b]c]                                             b
a[b[c]d]f                                           acf
[ab]c[df]                                           c
a[a]a[[a]]                                          aaa
abc[d[fgijk]nopq]rst[u[v[[w]]]xy[[[z]]]]            abcfgijkrstvwz
zyx[w]v[ut[s]r[[qp][kj]i]gf][d][][][c][b[][a]]      zyxvsia
```
**Other:**
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer (in bytes) per language wins!
  
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 7 bytes
```
\W\w*.
```
[Try it online!](https://tio.run/##K0otycxLNPz/PyY8plxLj@v//8Sk5OiU6LT0zKzs2Lz8gsLYouKS6NLosujo8tjY2IrK6OjoKiAjFgA "Retina – Try It Online")
* -7 bytes (50%) thanks to DLosc :)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~10~~ 8 bytes
```
e€Ø[œpm2
```
[Try it online!](https://tio.run/##y0rNyan8/z/1UdOawzOij04uyDX6//9/VWVFdHlsWXRpSXRxbFF0dGFBbHR2VmxmbHpabHRKbDQIJsdGJwGpxNhYAA "Jelly – Try It Online") or [see all test cases](https://tio.run/##nZIxbsJAFET7PQVnyG2i0RR/vSyyIYnBYLDLNBwgTerUqRAFUkorB3EusvzFkSKl@2y10u7TzJ/51Xy16lKa/7x@Du/4fqufHtJ4OY2Xj@Hoxq/zcNSXx5TEFzPrUcYJPK2kFA5ix1TMo6DZpAPt002z8T7OF@BdehqmMZZfLoMmUqbqNM9gkgsTZnWZG8@bYovFZ7FskdEkFqf9Qoi07ReEGqbQgInIrfCAuCirJZ9f6jU3zRY7tMBeazl02k@vF/4r7gbo13bfu7476OcWuy0aboB1TSwrllxEImjgyF1pGvyzp0zblHIF "Jelly – Try It Online")
Full program as we use Jelly' smash printing. Uses some tricks from [Jonah's J answer](https://codegolf.stackexchange.com/a/233885/66833), so be sure to upvote that as well!
-2 bytes thanks to [Nick Kennedy](https://codegolf.stackexchange.com/users/42248/nick-kennedy).
## How it works
```
e€Ø[œpm2 - Main link. Takes a string S on the left e.g. S = "a[b[c]d]e"
  Ø[     - Builtin constant; Yield "[]"
 €       - Over each character in S:
e        -   Is it a bracket?                      e.g. [0,1,0,1,0,1,0,1,0] 
    œp   - Partition S at the truthy indices       e.g. [['a'], ['b'], ['c'], ['d'], ['e']]
      m2 - Take every second sublist               e.g. [['a'], ['c'], ['e']]
           Smash-print and return                  e.g. 'abc'
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `s`, 4 bytes
```
øW4Ḟ
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJzIiwiIiwiw7hXNOG4niIsIiIsIidhKGIoYylkKGUpZilnKGgoaSkpJyJd)
```
øW   # Split on words (Matches sequences of word chars + single non-word chars)
     # (Used for dictionary compression algorithm)
  4Ḟ # Get every fourth item.
```
Beating Jelly :) -2 thanks to Aaron Miller.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0 [`-P`](https://codegolf.meta.stackexchange.com/a/14339/), ~~7~~ 5 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Vyxal was being too cocky for my liking! :D
```
q\W ë
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&flags=LVA&code=cVxXIOs&input=ImFbYltjXWRdZiI) or [run all test cases](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=cVxXIOs&footer=cQ&input=WwoiYWJjIgoiYVtiXWMiCiJbYWJdYyIKImFiW2NdIgoiW11hYmMiCiJhW11iYyIKImFiY1tdIgoiYVtbYl1dYyIKImFbW1tiXV1dYyIKImFbYl1bY11kIgoiYVtiXVtdYyIKIlthW2JdY10iCiJhW2JbY11kXWYiCiJbYWJdY1tkZl0iCiJhW2FdYVtbYV1dIgoiYWJjW2RbZmdpamtdbm9wcV1yc3RbdVt2W1t3XV1deHlbW1t6XV1dXSIKInp5eFt3XXZbdXRbc11yW1txcF1ba2pdaV1nZl1bZF1bXVtdW2NdW2JbXVthXV0iCl0tbVI)
```
q\W ë     :Implicit input of string
q         :Split on
 \W       :  RegEx /[^a-z0-9]/i
    ë     :Get every second element, starting with the first
          :Implicitly join and output
```
[Answer]
# [J](http://jsoftware.com/), 39 24 23 18 15 bytes
```
#~'_'(*=/\)@I.]
```
[Try it online!](https://tio.run/##XY7BCsJADETvfkXQQ1S0ei4IgiAInryOg7RbV1vBVqtVe/DX66pVwYRAkjcZklRNT62MfFHpyVB8V31PJov5tGrddaXt7miw7IxnHqtOY222qVjRACEMI1ptvHcaGKvS9/9gzUJjN3GyO@an4lJ@ZaFBhBfgPs0OdBhnFMCF5PUGoHQNVX5RG5a3a5HHwcfJje6mwPmEnEfgkBG7hDE3loiIZxq6r4ig9qse "J – Try It Online")
*-3 bytes and new approach thanks to FrownyFrog!*
## old answer, 39 24 23 18 bytes
```
(+:~:/\)@e.&'[]'#]
```
[Try it online!](https://tio.run/##XY7NCsJADITvPkVQMIpaPS8IguDJk9dxDu3W1bbgX7VqD756XbUqmBBI8k2GpFUzUCdjIyp9GYnxNQhkupjPqk7P3M1w2Z2sgraC2mLVbazsZidONEQEy5hOG@@dhtapDMwfrFlk3TpJs2N@Ki7lVxZZxHgBbnf7Az3GGQVwIXm9ASh9Q5Vf1Ibl7VrkSfhx8qO/KXA@IecROOyJLGXCtSNi4pmW/isirP2qBw "J – Try It Online")
*Saved around 10 bytes after reading [dingledooper's answer](https://codegolf.stackexchange.com/a/233887/15469) and realizing I didn't have distinguish between open and close brackets.*
*-6 thanks to some damn clever tricks by Bubbler!*
Consider `'a[b[c]d]f'`:
* `e.&'[]'` Is the input a bracket? Returns a boolean mask:
```
0 1 0 1 0 1 0 1 0
```
* `(+:~:/\)@` Transform that mask first by a scan using a not equal reduction. Only items with odd numbers of brackets to their left (including themselves) become 1. Then "not-or" `+:` that result with the original mask:
```
1 0 0 0 1 0 0 0 1
```
* `#]` Use that to filter the original input:
```
acf
```
[Answer]
# [Python 3](https://docs.python.org/3/), 45 bytes
Input is taken from STDIN, and outputs a list of characters, each on its own line.
```
n=1
for c in input():n^=c<'a'or n>0==print(c)
```
[Try it online!](https://tio.run/##JY1BjoMwFEP3OQViU9hNNbtqmItYrhQS0qYdhZSGFnp55odI0Zfl2M9xTdcxfG/vq/8bquOpGpbBNHVdb6E7KjdOlal8kBfn1LSncO7Mz0EfxA@/X10XJx9SY9qtiFaK7aZ7ozR6GgWdr@5hqMDiM9/egKIllP@xC5aWZG0ROyBzcjQzLF1BwrrsaUpVkzvPwl387c4wxgenZ8KMF/AW7rLKwEcE1WddxHphTnhyAh6RuN/oeXGElUnkfRlj5v4D "Python 3 – Try It Online")
The main observation is that whether or not a letter is wrapped in an odd number of brackets can be solely determined by taking the parity of the number of brackets preceding that letter.
### [Python 3](https://docs.python.org/3/), 48 bytes
Same as above, but outputs the entire string on one line.
```
n=1
for c in input():n^=not'`'<c!=print(end=c*n)
```
[Try it online!](https://tio.run/##JY3BboMwEETv/grKJdBb1FtUvmQ0VY2NEyeVcYhJID9P11iyVrPjnTdxTZcxfG2vi/8bquOpGpbBNHVdb6E7KjdOlal8kBfn1LSn8NOFMR1@D9/mo4uTD6kZgu3MZ2i3sraSbTfdG6XR0yjoPHUPQwUWn3n2BhQtR/kfu2BJya0tYgdkTj7NDEtXkLAue5oS1eTOs3Bnf70xjPHO6ZEw4wm8hLusUvAWQfVeF7GemBMenIB7JG5Xep4dYaUSuV/KmLn/ "Python 3 – Try It Online")
### [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 49 bytes
A `lambda`-based solution which is just slightly longer, in comparison:
```
lambda L,n=1:[c for c in L if(n:=n^(b:=c<'a'))>b]
```
[Try it online!](https://tio.run/##nZJNbsMgEIX3PgW72FJUKeqmskpPkBtMp9KAS0LiYGJj5@fy7hBXqtTdhA0I5tMb3pt4S/suvL7Ffnb6c27pZBpS23XQmxqscl2vrPJBbZV3Zah1@CpNre37ilZV9WFwvux9@602dcFVca26MUWl1Yli2fohrfPtmMrqZYit570qVOx9SKUr@aVSWj@QaiZjlXQxUxAYlJJkCyA5xmIGLIqbLADlv1v@hs9xxgI@pcdmCm355TIoImmJjv1sRHLNgkm7zInnSZHZYrJYbhGdSMwt8wWNQ9l8ASGbSSjAiOgReANu5w9HDF08Yz8kGGECuHAs1xvnc@cD/gvuAXDpdLkX99uViycYEwzYA5wjwvGAHncOoWHDIWfFbuBfe8xMg6cf "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 40 bytes
```
StringSplit[#,"["|"]",All][[;;;;2]]<>""&
```
[Try it online!](https://tio.run/##PY7JEoIwEETvfkas8oQXry6lf2AVx64@DGAwiogY9@XXcUAgl7z0dLrnIH67OYh3sVR2XoW@dHkaFpnzGAYG5m1oglWWEZjqmZCzhTGjaq0@tYwXdjnk6BvGkn9fAyNRbAK9ELEBSAsSIWajsPewA3Wzw5rZh@inpOcusg5nq9YG2r4KiW0nQg0T/l@RDmBTt9szPxYnlmePC67ATcvuD219KjTe5@Ou6hUXjzNL4FQQ@x0dU0skugTqpbSYTfrgU/0A "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~33~~ 32 bytes
*-1 byte thanks to [@Shaggy](https://codegolf.stackexchange.com/users/58974/shaggy).*
```
function(s)gsub("\\W\\w*.","",s)
```
[Try it online!](https://tio.run/##pZLNDoIwEITvPoWpFzDGN/A5PAx72NKUoAkq5Ud5edwiYvTW2lMP/Tq7M1OP9jDatsqb8lIlLi1cqxOVZccs67d7tVNq59LRJop1rtLNOvQItvI0NEXwPMHgKPglrJFThLCehClq62Vn@ofWOegPbTE83LQP7fFQnpeoxXMTqM1mgSPmnnviWxZsmp6F/dBkQ1e2S0NhbKD27BeTGM4UBjPzuyYGtihPZ6ou1xvVrkGLDuglwPtDkhzk8vu3YBMjr7t@8B8Nj7sgHdoGjmrgdiWcT1RSYQlGQoFPVVyir1EF61zJ4xM "R – Try It Online")
Simple regex-based solution.
[Answer]
# [Zsh](https://www.zsh.org/), 19 bytes
```
<<<${(e)1//[][]/\`}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724qjhjwYKlpSVpuhabbWxsVKo1UjUN9fWjY6Nj9WMSaiEyUAU3daKVEpOSo1Oi09Izs7Jj8_ILCmOLikuiS6PLoqPLY2NjKyqjo6OrgIxYpVioJgA)
Replaces `[` and `]` with ```, and `(e)`xpands the backtick substitutions. For example, `A[[]BCD]` becomes
```
A```BCD`
```
The contents of backticks when in strings are evaluated as commands. Since there are no commands made only of uppercase letters, the bits in backticks do nothing and aren't included in the output.
If we can't assume input is uppercase, the same method can be adapted to force it to uppercase:
## [Zsh](https://www.zsh.org/), 26 bytes
```
<<<${(L)${(eU)1//[][]/\`}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724qjhjwYKlpSVpuha7bGxsVKo1fDSBRGqopqG-fnRsdKx-TEJtLUQBVN1NnWilxKTk6JTotPTMrOzYvPyCwtii4pLo0uiy6Ojy2NjYisro6OgqICNWKRaqCQA)
---
## [Zsh](https://www.zsh.org/), 21 bytes
```
<<<${1//[][][a-z]#?/}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724qjhjU7SSrm5qRUlqXkpqSnpOfpJS7IKlpSVpuhZbbWxsVKoN9fWjY4EwUbcqVtlevxYiB1VyUydaKTEpOTolOi09Mys7Ni-_oDC2qLgkujS6LDq6PDY2tqIyOjq6CsiIhZsLAA)
A less interesting alternative that uses the equivalent of the `\W\w*.` regex method used by some other answers: `[][]` matches any square bracket, then `[a-z]` any letter (`#` means "0 or more times"), then `?` matches any single character.
Must be run with `--extendedglob` to enable the `#` pattern feature.
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), ~~96~~ ~~89~~ 71 bytes
-25(!) bytes thanks to [Daniel Cristofani](https://codegolf.stackexchange.com/users/10650/daniel-cristofani)
Uses `()` as brackets.
```
,[[>+>+<<-]+++++[>--------<-]>[-[[-]>>[<]<[.<<]]]>[>-[++>]<[<]]>[-]<<,]
```
[Try it online!](https://tio.run/##LYhbCoNQDAW3k0OMKwjZSMiHDyxWEGtrtd38bS50zsdwpt@7eZ2OYSmlcTc2VpXgipv8yWIu7ilzDfVWNSKbiTNbBq1PQrWJUr6fi0686XjREzvRYwMtd8y4TaARVDeA@lQH/AA "brainfuck – Try It Online")
~~This is the most complex brainfuck I've ever written and I had quite a few troubles with getting the pointer back to a common position after branches, so I suspect there is some room for optimization.~~
With some comments:
```
                              tape layout: _; input1; input2; parity flag
,[                            while loop: runs as long as there is input
  [>+>+<<-]                   make two copies of the input to the right
  +++++[>--------<-]>         subtract 40 from the first copy
  [-[                         if the result is not 0 or 1:
    [-]                         set first copy to 0
    >>[<]<[.<<]                 print second copy is not set
                                pointer is now at _
  ]]
  >[                          if the pointer is at input1
    >-[++>]<[<]                 toggle the parity flag
  ]                  
  >[-]<<                      set second copy to 0
,]
```
[Try it online!](https://tio.run/##hZLfboMgFMbvfYpzCbEu7bKrjvAixjTUomW1wOAw517egZrFpH92SDwh8fd93wGOTijdhPoyjvC0UFgJnRhMwD0c3kFpG3C39Nd3sMIpHKDpRJttymdK/Vl1UcoYuwcXtAfh4063qeNZOgnKz7IZQMlznjNWVHeEruIiAXsDtbFKejBN4mcU0Ewbp9pz0slTlbxYKgryPx0fjuhEjfC2hcaZ6wQ2ynlMykNKUTyeSM2uTvrQYYquDcIWjIPdPks/lHfDL9YSV04p9HZiOC9ZxcoXxm5Z65TGSNZGn2ZsMY1iGfxT1kRYuhnpQSAcIlNV8cOf3Noy5IqO5PwE5rxFmec8Jr6TF03bxguf@NUjia63PlOMomLs8XGtB5/Oa1ON48/wTXr6RQISTx0hn5aSywdVtG0oOVGSVk3JMTZB6S8 "brainfuck – Try It Online")
[Answer]
# [AutoHotKey](https://www.autohotkey.com), 44 bytes
```
#UseHook
[::
]::
A:=not A
BlockInput,%A%
```
You need execute it as Administrator permission. And you can always back to normal input status with `Ctrl-Alt-Delete` if you are in trouble.
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 10 bytes
```
@UW:a^`\W`
```
[Try it online!](https://tio.run/##K8gs@P/fITTcKjEuISY84f///4lJydEp0WnpmVnZsXn5BYWxRcUl0aXRZdHR5bGxsRWV0dHRVUBGLAA "Pip – Try It Online")
### Explanation
The key observation is that the two types of brackets don't need to be distinguished...
```
    a       First command-line argument
     ^`\W`  Split on this regex (any non-word character, i.e. a bracket)
 UW:        Unweave (the : is needed for precedence reasons, unfortunately)
@           Take the first of the unweave results
```
Unweave turns a list like `[1 2 3 4 5]` into `[[1 3 5] [2 4]]`, so `@UW` applied to the split results gives every other result, starting with the first.
[Answer]
# JavaScript, ~~27~~ 26 bytes
Using [pajonk's RegEx replacement approach](https://codegolf.stackexchange.com/a/233899/58974); be sure to `+1` them if you're `+1`ing this.
```
s=>s.replace(/\W\w*./g,``)
```
[Try it online!](https://tio.run/##PY5LkoIwGIT3HsMVTDl4Ar3GLNquMiSEAhkSCeLj8vgTI6t81enH36pJBT00fvztnalme5jD4RiKofKd0lW2P/2d7j/Fvt6dz/msXR9cVxWdqzNstqrU2508KBkBKoEqoRkVrh4mKDX4USSW7IjMtU3SZuVv97KSkku9oV03YWz6UZQyRX6nDGzdtBf2zl85hBE3TMBdxh5PWX0JRO/r@RB1wm1E4ABcPXFp2bC2hJEjsBwlw4ztGxb/ymc2z@c3)
## Original, 44 bytes
Adaptation of [my Japt solution](https://codegolf.stackexchange.com/a/233906/58974).
```
s=>s.split(/\W/).filter((_,y)=>++y%2).join``
```
[Try it online!](https://tio.run/##PY5NbsMgFIT3OUakSqCkROreuUYXr6MGg7FwXEMMceNc3sWUeMWnYX5eJycZ1Gh9fB@cbhZTLaE6BxF8byM7fX2euDC2j83I2Pdx5tX5cJjfPrjonB0ul0W5Ibi@Eb1rGe32slb7Y3qoRgaSBWRNClnB5kGBWhH@lRQrdsqMrS2l9cav7nWlJNd6DbNtkjblRyKVSeA1pcm0trticP6GMUS600T0m8Yec1p9Jsje5/xI6kT3SAEj0c2Drh0sWgPS6Qhaj0rDyO07iB/pmeF8@QM)
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~55~~ 52 bytes
-3 thanks to dingledooper.
Scans through the string and increments a even-starting depth counter, printing any characters on an even depth: as the input is guaranteed to be balanced, the starting depth will always be an even number. Uses Jonah's trick of only scanning for brackets regardless of direction.
```
l;f(char*s){for(;*s;s++)*s>96?l%2||putchar(*s):l++;}
```
[Try it online!](https://tio.run/##dVJNT8MwDL33V1hFk9pscOCABGHjD0zcOFk@pAnZAmXdmrTAYL99OOu0tSBycPz88fwSWV8utN7vS2kzvVS18PmXrepMCi/9eJwLP7u9eShH19/f6ybEioxL7srxWO72F26ly8Y8w70PxlVXy1kyCJWuiLHErQK8KbfK2sqZHL4SgMgEwiNNIwJIVaHTydHFgk4AVQ@oAjWdMjTooR4oNNI5w3Q9CjxgGkxjVjPA/flRTY8tSjBkB/rQ2F6FIh6iiPpyDNqFe3mlVbXeUO0DNtgivrOQj09WtGXnVL/9/OBMi01ATzXiZk34@kKOFpbQsDiMglkI9aY8Ps3n7OwmINSvX@XrYDu36Kz@/zp/jTk3d23anomUOjYdXsZvat@3McLyW@/UX10iRNPIhHHcsTD1E2imSoIIEni9fJamebcffNY1743N0pGH6QyYWYRcdimbicDLKYeFkPll1ZQGimfAkac89jTHul2y2/8A "C (gcc) – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 50 bytes
```
f(h:t)=[h|h>']',even$sum[1|b<-t,b<'a']]++f t
f x=x
```
[Try it online!](https://tio.run/##DcZBDsIgEAXQvaeYNE3QtC7cmuJFfmYBCoJtsRZa0fTu6Fs9p2JvhqEUu3fndJBwm7sIFq1ZTajjMuK06e6YWt0JJZibxlLaWcoyl1H5QJKm2YdENVmqlL7iBnv3j57Dc3rxHBMWrMCbmfMHwPcfrsoP "Haskell – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `K`, 24 bytes
Thanks to [exedraj](https://codegolf.stackexchange.com/users/78850/exedraj), [emanresu A](https://codegolf.stackexchange.com/users/100664/emanresu-a) and [hyper-neutrino](https://codegolf.stackexchange.com/users/68942/hyper-neutrino) for guiding me through my Vyxal journey's beginning.
```
ƛ91≠*;ƛ93≠*;'[¥¬|¥¬£];C∑
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=K&code=%C6%9B91%E2%89%A0*%3B%C6%9B93%E2%89%A0*%3B%27%5B%C2%A5%C2%AC%7C%C2%A5%C2%AC%C2%A3%5D%3BC%E2%88%91&inputs=zyx%5Bw%5Dv%5But%5Bs%5Dr%5B%5Bqp%5D%5Bkj%5Di%5Dgf%5D%5Bd%5D%5B%5D%5B%5D%5Bc%5D%5Bb%5B%5D%5Ba%5D%5D&header=&footer=)
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 46 bytes
```
x=>[...x].filter(x=>(z^=b=x>'z')>b,z=1).join``
```
[Try it online!](https://tio.run/##DchhCsIgGADQ46hQQgfQi0QxdTo08Vtqy/zw7LZ/jxfUoYrJfq/XBKudTswm5J1z3h7c@VhtpmfQ/hRaNEk6YVJfurgxHsCnZZkGUoFoeYSNOkqUNrii23x4jQT7e@RS8YMH4neM0X6I2E8Mwtj8Aw "JavaScript (Node.js) – Try It Online")
Port of dingledooper's answer thanks to dingledooper.
# [JavaScript (Node.js)](https://nodejs.org), 51 bytes
```
x=>x.replace(/[{}]([^{}]*)/g,(a,b)=>i++%2?b:'',i=0)
```
[Try it online!](https://tio.run/##DcbRDoIgFADQr2lAkrYe27APcbUBAsOcEJhRd/fbyZezM8lNZp18XE9LGE21ohbRlzaZOEttaDcA3unw2D2yznEquWKi901zuNzUlRDuxZlVHZYcZtPOwVFLiVQaRrDOT09cQnxhyiu8YQP4IGL5AsBvDxLG6h8 "JavaScript (Node.js) – Try It Online")
This makes use of the fact that after an even amount of open or close brackets, the bit of the string up until the next bracket should be kept. After an odd amount, it shouldn't. For example, on the demo input string, the following happens:
```
Full:    abc[d[fgijk]nopq]rst[u[v[[w]]]xy[[[z]]]]
Valid:   abc  [fgijk     ]rst  [v [w ]   [ [z ] ]
Invalid:    [d      ]nopq    [u  [  ] ]xy [  ] ]
```
We just smoosh the valid half together, remove all the brackets, and we have our answer!
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 22 bytes
```
{((~≠\⍵∊'[]')/⍵)~'[]'}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/WkOj7lHngphHvVsfdXSpR8eqa@oD2Zp1IGbt//8A "APL (Dyalog Classic) – Try It Online")
**Explained**
```
{                    }   ⍝ Monadic function, takes string on left
      ⍵∊'[]')            ⍝ Boolean mask for characters which are braces
 ((~≠\                   ⍝ Scan the mask by not-equal and negate (Mask for characters that is needed to kept with braces)
             /⍵)         ⍝ Filter the input using the scanned mask
                ~'[]'    ⍝ Remove the braces
```
[Try it online!](https://tio.run/##bZBBTsMwEEX3OcXfNZGIuAMLdt3AElhMnUlsxbVDPKGqEF0DUo@AxCW4UC4S7AYkimJpFrZm3vse6mxZ7cn6plSWQjBqmp6xcF5ijccPrL2jyijUg1NivLuAUMsBQXrjGngHy7Vk89B4/Bpf31d3D6viLytxrry3TA5bCi1q30Np6kkJ9wE7bZQG9YxNfOKQIc8P49vn/UKuxLpVESSaZ9hmD@el5MeBLMhVcNyQMPL1gko0CUyIPVxxBfFouRPsjOgfeZGd@S7jn4oz@7WxEXXyG9cNgiGkTaR7iMFcxKZc2f/kh7SXX8gNb/0Tn4Zm7TR9Aw "APL (Dyalog Classic) – Try It Online")
# [APL (Dyalog Classic)](https://www.dyalog.com/), 24 bytes
```
{((~2|+\⍵∊'[]')/⍵)~'[]'}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/WkOjzqhGO@ZR79ZHHV3q0bHqmvpAtmYdiFn7/z8A "APL (Dyalog Classic) – Try It Online")
Monadic function, takes the string on right
Approaches in array oriented languages are really neat
[Answer]
# [jq](https://stedolan.github.io/jq/), 19 bytes
```
gsub("\\W\\w*.";"")
```
Uses the regular expression from [tsh's answer](https://codegolf.stackexchange.com/a/233895/90812).
[Try it online!](https://tio.run/##yyr8/z@9uDRJQykmJjwmplxLT8laSUnz/3@lxKTk6JTotPTMrOzYvPyCwtii4pLo0uiy6Ojy2NjYisro6OgqICNWCQA "jq – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 16 bytes
```
ＦＳ¿№βιＦ¬﹪Ｌυ²ι⊞υι
```
[Try it online!](https://tio.run/##HYs7DsIwEAWvsuVaCg1tSiokQJEoVy4Sx3EMljc46/C5vDF0T29mzNwnw30oZeIEeIxLlqskHx0qBX4CPHCOgkMDvh5/6cKCZx5zYDzZ6GTGrBrYq8q7Wgp61YINq4UurxX@0raUfjA00uT87a4jLw@dVqFMG9FTa/16E9GnDl12W/gC "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Prints lowercase letters unless an odd number of other characters have been recorded.
Alternative solution, also 16 bytes:
```
⪫Φ⪪⪫⪪Ｓ]¦[¦[¬﹪κ²ω
```
[Try it online!](https://tio.run/##RYqxCsIwEEB/pXS6QF1c3QsKitDxuCGmWmNDLsZLW/35GFFweTwez1x1NKxdzsdovcCOrYfWOjlH6IKzv/LVrQ9JOinjAKqpaqo/xD8PLLDnPjmGsanWSpU2K7XJWZ8M9ngZ7G0kz@FO8SGYcEKciWh5IuKrCOXV5N4 "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Replaces `]`s with `[`s, then splits on `[`s and outputs alternate elements.
[Answer]
# [Haskell](https://www.haskell.org/), ~~66~~ 61 bytes
```
f(x,y)c=(x-sum[x+x|c>'z'],y++[c|c<'{',x>0])
snd.foldl f(1,"")
```
[Try it online!](https://tio.run/##BcFBDsIgEADAu69oiAkQsKl36UeaHnCBlgirEU220r4dZ1ZbHj6l1oIgvUkwgi7lmydStMPIf3zWm1IT7HDjlWsah1meFlPQ9eGZXOqCuGrGZMs2onm9I37OC7N3qA7RYfU@H/6IkbU/ "Haskell – Try It Online")
Haskell doesn't really do regex.
[Answer]
# [Python 3](https://docs.python.org/3/), 40 bytes (using regex)
```
lambda s:re.sub("\W\w*.","",s)
import re
```
[Try it online!](https://tio.run/##JY3BjoMwDETv@YooJ1ihSqu9VWJ/Yw/Gh4SQNi0NaRJK6c@zNlys8Xj8Jq7lOoWfzbXdNuqHsVrmcxpOeTaV6v665eukGqWaXAv/iFMqMg3bcvXjIL/PQo4@DLKVPsS5VLWQMflQKnYbqdpfqRrp9rWuN216ocFgL0Dz1AZ6FICHjzxND0iaQnyHXeDxRVl7iB3AHI4yw6I7kGAdexrpVSPuPAvu4m93DFN8YsoFZngBLMR9r1TwIYHis77JesFcIGMCeEaE@w09XhyCpUrgfipD5v4D "Python 3 – Try It Online")
## Version without lambda, 44 bytes
```
import re
print(re.sub("\W\w*.","",input()))
```
[Try it online!](https://tio.run/##LY7BboMwEETv/gprT1ChSFFvkehv9LDZg8EmcUINMSZAqn473YVcVuPZnTful3Ttwudad9aVEQBW/9N3MenoVB99SFl0h2GsMjh/n6ePAxQAhQ/9mLI8z1cOqNYHp0vNyrqGc8Zm@UnpS9tVptWyVeymMYb9oaarb50@8s07@uYpvTeKW2govzQU2gVbAvDOza7O5JvFL2wBOEnXX76aqlYGK6oVGpmmwpoU0u6TzKpGYs1HssdN0J7iW7uLDSAcORWGpWZHom3EM8RRQ7TxLDYXf7tT6PoHxSHhiE/EibnzwgUvFqRey8zWE8eEA0XER094v5GnS0NouRKln8tIuP8 "Python 3 – Try It Online")
Thanks to @emanresu A for the lambda version
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 12 bytes
```
{x&=\x>:93}#
```
[Try it online!](https://ngn.bitbucket.io/k#eJydU8FugzAMvfsrUDdNmzRph50GWn/Es9QElIp2WlugFFp13z7bUAbdZS6HiDh+ec+OX4hPzcP7RzOP317PdwBVfLrH9ruIQxRFTbLYrJPHRXD5Z9IkbVI80RkqnDmfzhJdSbfoSQP9Hp3un2eXc48pKaA/pz8X0FXAp0jTDOagK5DGJsyihLkyCWWj0JU80Usi0A85gqKgWWFUBWaBxpWgI+Z1pOKc+1WbYVjmqzV9bbY7KsoK91gjHlhf07LQI//0BWkeZ9SHYwc/tg0n1rivsKQCcbclXK8op2UgzFg8Sk0skXpiBtRlLuQAL8BXRtaPMaBdsOJS0LYYYUwmDbaSedBJMcOkNroNJ3N3E5+O5y24boYtuO7pZGBNdBn0VrCplBdXv5hgHgZPmcgCDLYz4KQjF2Ma2JyD/1p3gpt4GGz27a7oHQw/AARD6g==)
Takes advantage of the input restrictions, i.e. only having to deal with lower cased characters and `[]` as the brackets.
* `{...}#` set up a filter, removing items from the (implicit) input that do not match the criteria in `{...}`
	+ `x>:93` determine which characters in the input are letters, updating `x` inplace (ASCII codes for `[]` are `91 93`, `a..z` are `97..122`)
	+ `=\` do an equals-scan over this (characters at an even level of nesting become 1, otherwise are 0)
	+ `x&` take the logical and, essentially asking "is this a letter AND is it at even level of nesting?"
[Answer]
# [Ly](https://github.com/LyricLy/Ly), 37 bytes
```
1s>ir['aL:[pfpl!sp0]p![pl[p:o0]pp0]p]
```
[Try it online!](https://tio.run/##Fce7EYAgFATAWohMNSWwAju4uQB1cFBGnuC/ecRs1z85N6l1EZXpNMSKV0lqioJ4iA6Ff5mz6QeMsJObF65BNsa048AJXCTvB8BbwA8 "Ly – Try It Online")
This code takes advantage of the input constraints that the characters will only come from the set of characters `a-z` and `[` or `]`. Which means checking to see if the codepoint is less than the codepoint for `a` is sufficient to identify the brackets. It also relies on the constraint that only valid sequences of open and close brackets will given. That allows each bracket to be a "on/off" toggle for the print setting, since it doesn't matter whether it's an open or close, it will always change the even/odd state of the accumulated groupings.
```
1s                                    -- Set "true" as initial print boolean state
  >                                   -- Change to a clean stack
   ir                                 -- Read all input as codepoints, reverse stack
     [                              ] -- Loop to process each input codepoint
      'aL                             -- Compare top of stack to "a"
         :[p      0]p                 -- if/then, true is codepoint is "[" or "]"
            fp                        -- Pull codepoint forward and delete
              l!sp                    -- Flip "on/off" boolean print state 
                     ![p         0]p  -- if/then, true if codepoint is "a-z"
                        l             -- Load print boolean state
                         [p  0]p      -- if/then, true if we should print the character 
                           :o         -- Duplicate the codepoint and print one copy
                                p     -- Delete the current codepoint from the stack
```
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 439 bytes
```
,[>[-]>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<[->>>+>+<<<<]>>>>[-<<<<+>>>>]<[-<->][-]>[-]<<[->+>+<<]>>[-<<+>>][-]+<[[-]>[-]<]>[[-]>[-]+<<<<<<[->>>>>>[-]<<<<<<]>>>>>>[-<<<<<<+>>>>>>]<<<<+>>>]<<++>[-]+<[[-]>[-]<]>[[-]>[-]+<<<<<[->>>>>[-]<<<<<]>>>>>[-<<<<<+>>>>>]<<<+>>]<[-]+<[[-]>[-]<]>[[-]>[-]>[-]<<<<<[->>>>+>+<<<<<]>>>>>[-<<<<<+>>>>>][-]+<[[-]>[-]<]>[[-]<<<<.>>>>]<<]<<,]
```
[Try it online!](https://tio.run/##tY/dDoIwDIUfqOATNLxIcy4Ag0ESoyj@vfxsKV2MIdy5sXG6nn3tmrHuT93UDomlBPPWXv0OO9OVCglJ/xtRgudmtDpVZBreiUkyCc1yWSHb1Txb4TY1WY5YwqF7tM@c8f4@P0DEHpKHCK3C@9uALsxA4htIGUfe/zooX3bW8v5V1BrC0rulkH4FUnq/nvLAXaabXDGKXM6Q4Ygehw6yh9hsIY3@auAD "brainfuck – Try It Online")
---
Generated using a self-written yet poorly optimizing brainfuck compiler still under development. Its *brainfuck macro assembler* source code without the prelude can be seen below. I am certain a carefully layed out tape together with hand-written brainfuck would dramatically improve this byte count.
```
(macro ppcg233884 () (
    ; define parity cell
    (let:nve $parity 0 (
        ; read in character stream
        (let:nve $char 0 (
            (getc:w $char)
            (while:re $char (
                ; check if it is a bracket and update parity
                (let:nve $wasbracket 0 (
                    (let:nve $bracket 91 (
                        ; '['
                        (sub:ra $char $bracket)
                        (ifnot:re $bracket (
                            (not:a $parity)
                            (inc:a $wasbracket)))
                        ; ']'
                        (inc:a $bracket)
                        (inc:a $bracket)
                        (ifnot:ze $bracket (
                            (not:a $parity)
                            (inc:a $wasbracket)))))
                    ; only print on even parity when it was not a bracket
                    (ifnot:ze $wasbracket (
                        (ifnot:re $parity (
                            (putc:r $char)))))))
                (getc:w $char)))))))))
(macro main () (
    (ppcg233884)))
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 6 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Aм¡ιн˜
```
I/O as a list of characters. If a nested list output is allowed, the trailing `˜` could be removed.
[Try it online](https://tio.run/##yy9OTMpM/f/f8cKeQwvP7byw9/Sc//@jlRKVdJSSgDgZiKOBOAVKpwFxOhBnAnEWEGcDcSwQ5wFxPhAXAHEhVKwIiIuBuASqtxRKl0FpEC6HqoXhCiCuRJIH4So0NbFKsQA) or [verify all test cases](https://tio.run/##PY49DoJAFISvQrb2DvS2lpMpdlkxYCK/ongAa2Nt4zFMtJHSxHAGL4KPdaWbzJuZ72WVNslyaNpQBZ/jOVBhu@hOQ3ft78/r@9Y/XpdhPhugtInULFAahk5Ae6ENIjqHU4ZemAj8OVLzcTjNaU3adtL/7ZHim@O8ZTwxYWN/0ZQxTf5RFvEqSdfcZHnBsqqxRQPsBLZvhXoQ4bKHdi9ug22NiiVQ5MQ6ZcJVTFh5AuNTAqZb5xc).
**Explanation:**
```
A       # Push the lowercase alphabet
 м      # Remove all these letters from the (implicit) input-list
  ¡     # Split the (implicit) input-list on the remaining characters ["[","]"]
   ι    # Uninterleave this list of lists into two parts
    н   # Only leave the first part of sublists
     ˜  # Flatten this nested list into a single list of characters
        # (after which it is output implicitly as result)
```
(Could also work for mixed cased letters by replacing `A` with `á`.)
[Answer]
# [V (vim)](https://github.com/DJMcMayhem/V), 19 bytes
Thanks to [Aaron Miller](https://codegolf.stackexchange.com/users/101522/aaron-miller) for this two bytes shorter version.
```
äh:s/]/[/g
òf[df[òx
```
[Try it online!](https://tio.run/##FcXLDYAgFATAu81wt5XNHlQEPzFBQQTrsQJaoLCnZg4TReoztV5RQdmmFgNtUEsSwbi5kHnnhIsRZ4DnAeyOWBfOtIbQxG8g@q@OfAE "V (vim) – Try It Online")
---
# [V (vim)](https://github.com/DJMcMayhem/V), 21 bytes
```
xPP:s/]/[/g
òf[df[ò0x
```
[Try it online!](https://tio.run/##FcWxDYAgFAXA3mWwdgr6l1eoCFFjgoIIjsUKDvbVXHFJJGvdBUUF5ZqnWhiLp7ZZBNPmY@FdMi4mnBGBB7B7Yl0401nCEL@RGL568gU "V (vim) – Try It Online")
## Explanation
```
xPP       " Duplicate initial character,
          "     since `f[` would else skip it.
          "     If the input is empty, error out.
:s/]/[/g  " Unify all brackets to `[`.
ò         " As long as necessary,
 f[       "     keep everything until even `[` and
 df[      "     discard everything until odd `[`.
ò         " End the loop.
0x        " Remove the duplicate character.
```
[Answer]
# [Curry (PAKCS)](https://www.informatik.uni-kiel.de/%7Epakcs/), 55 bytes
```
f(h:t)=[h|h>']',0<foldl(*)1[-1|b<-t,b<'a']]++f t
f[]=[]
```
[Try it online!](https://tio.run/##Fci7DsIgFADQvV9BGhPAFmNXAu5OupM78AxEig3SwaT/jvGMx@61ftmmX/bTeyCRNypVPOINA56vIryzy@RMF8WWwwjWZiOwxgDTFFAbggKpoK86FcQ5elafd@cv9wcidPiv3Goq7RRGbaxypbiivF/BQ0pj/wE "Curry (PAKCS) – Try It Online")
This is based on [Lynn's Haskell answer](https://codegolf.stackexchange.com/a/234976). There are two difficulties adapting it to Curry however. The first is that curry doesn't have falling through so the case `f x=x` needs to be replaced\* with `f[]=[]` for an extra byte.
The next is that curry doesn't have `sum` so we need to replace it with some sort of fold. The most efficient way to do this is to actually make a `product` instead of a `sum` since it is way cheaper to check if something is positive than whether it is even.
\*: This doesn't actually behave like I would expect. I'm not a curry expert. However in both the expected behavior and the actual behavior it fails so...
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~66~~ 63 bytes
```
f(char*s){for(char*z=s,n=0;*z=*s++;*z-91&&*z-93?n%2||++z:++n);}
```
[Try it online!](https://tio.run/##rVJNT4NAEL3zK1aSNlDaxOpJa2uaqImJBxOP4xwW6NbtB1CW0pZa/3qdpR4AT1vlwD7YeW/fzrygNw2C41E4wQdPO8rdizg94WKoutHwckCgozyP1t5Nv93Wy/V91Lr6/PS84tbzIndwOOaxDFk2UVnJZR3ZZScQu2xvnbC/FqCydDGJHOl6fRxYjD6DZOfQTpdJl34IjTWQgjkXenuZnLZj17UYS1IZZcKx717Hb2@PDyNGT0uxrxG93yObVHQl8ScLNanWP42fXxr17GJYYf0cMrAOlrXkMnJc8l3eyOZ@QDWmT0nTVn5EwEdzGZtXNYCfpVGz4UOAZ9jwqzbwnI786gf@g4gfAP7dCY3GuK@/RbSKoUx9vDoiNJ3QzInNw6bGGZepx0xn1bSvtl@3oW@CwrQdohl3CIWZk3rcgSONhqORhs05b6QsBDGVszlGcbLCVGWwhhxgQxPf7mj0BYHGEZpWcqg63xQVvWK3JWYO6wwUpgCrBGE@Q4lTgRDS@EDHgDqIVeOalitZGjscvwE "C (gcc) – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 53 bytes
```
s?(x:r)|x<'a'=(1-s)?r|s>0=s?r|s<1=x:s?r;_?q=q;f=(0?)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/n6vYXqPCqkizpsJGPVHdVsNQt1jTvqim2M7AthhE2xjaVlgBWdbx9oW2hdZpthoG9pr/cxMz8xRsFTLzSlKLEpNLFNL@AwA "Haskell – Try It Online")
]