[Question]
  [
*[Related](https://codegolf.stackexchange.com/questions/249908/extract-strings-from-text)*
We start with the string `a`, and forever append to the string a comma followed by the string quote-escaped, where quote-escaping means doubling all quotes in a string, and then surrounding it with an additional pair of quotes.
In the first few steps we will get:
* `a`
* `a,'a'`
* `a,'a','a,''a'''`
* `a,'a','a,''a''','a,''a'',''a,''''a'''''''`
If we continue to do that forever, we get the following infinite string:
`a,'a','a,''a''','a,''a'',''a,''''a''''''','a,''a'',''a,''''a'''''',''a,''''a'''',''''a,''''''''a''''''''''''''','a,''a'',''a,''''a'''''',''a,''''a'''',''''a,'''...`
If create a sequence, which is 1 at indices that string contains a quotes, we'll get the following sequence:
1. `0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, ...`
Alternatively, we can look at the indices of quotes, and get the following sequence (this is 0-indexed):
2. `2, 4, 6, 9, 10, 12, 13, 14, 16, 19, 20, 22, 23, 25, 26, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 42, 45, 46, ...`
Your task is to output one of these numeric sequences.
## Rules
* You can choose whether you use 0-indexing or 1-indexing.
* If you output sequence 1, you can use any truthy/falsey values instead of 1/0, or any two different consistent values.
* If you output sequence 2 (the one with the indices), you can choose if those indices use 0-indexing or 1-indexing.
* You can use one of following output modes:
	+ Take \$n\$ as an input, and output the \$n\$-th element in the sequence.
	+ Take \$n\$ as an input, and output all elements in the sequence up to the \$n\$-th element.
	+ Take no input, and output the entire sequence forever.
* You can use any reasonable input/output format.
* [Standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are disallowed.
This is code golf, so the shortest code wins.
  
[Answer]
# [Python](https://www.python.org), 57 bytes (@Steffan)
```
a=b="/"
while[print(end=b)]:b="/\%s\\"%repr(a)[1:-1];a+=b
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3LRNtk2yV9JW4yjMyc1KjC4oy80o0UvNSbJM0Y61AMjGqxTExSqpFqQVFGoma0YZWuoax1onatkkQA6DmwMwDAA)
### Old [Python](https://www.python.org), 58 bytes
```
a=b="/"
while[print(end=b)]:b="/\\%s\\"%repr(a)[1:-1];a+=b
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3rRJtk2yV9JW4yjMyc1KjC4oy80o0UvNSbJM0Y61AMjExqsUxMUqqRakFRRqJmtGGVrqGsdaJ2rZJEBOgBsEMBAA)
Prints the entire sequence using `/` for `0` and `\` for `1`.
[Answer]
# [J](http://jsoftware.com/), 22 19 bytes
```
{1&(],1,~0 1,+#])&0
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/qw3VNGJ1DHXqDBQMdbSVYzXVDP5rcqUmZ@QrpClpK2TqGZpDeIbmCtV6CgY6IGSIQUIYhkgM/LLIDGQthhhcKpj2HwA "J – Try It Online")
*-3 thanks to ovs!*
Quite slow, as we iterate n times and take the nth result.
TIO link shows first 17 terms.
Approach is straightforward recursion:
* `{` nth item (0-indexed) from...
* `1&( )&0` Iterate n times, starting with 0, and using a constant left arg of 1...
* `(],1,~0 1,+#])` Bookend `+#]` (to be explained below) with `0 1` and `1`
* `+#]` The only interesting part, really. This is how we double up the quotes. Consider `0 0 1 0 1`:
	+ `+` adds 1 to every element, taking advantage of the fixed left arg of 1:
	
	
	
	```
	1 1 2 1 2
	
	```
	+ `#]` use that as a duplication mask for `0 0 1 0 1`:
	
	
	
	```
	0 0 1 1 0 1 1
	
	```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 16 bytes
```
0w?(:k≈$vß"1Wf)Ẏ
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCIwdz8oOmviiYgkdsOfXCIxV2Yp4bqOIiwiIiwiMTUiXQ==)
Same idea as the Jelly answer.
[Answer]
# [lin](https://github.com/molarmanful/lin), 57 bytes
```
.\n0\;.n e*.n `t
dup \; `' `flat1`,0`,1`+ `+
dup \; e&
1,
```
[Try it here!](https://replit.com/@molarmanful/try-lin) Returns an iterable with the first *n* elements.
The code above extremely inefficiently runs through *n* iterations. For testing purposes, the following code is equivalent:
```
100 ; `_
.\n0;.n `t
dup \; `' `flat1`,0`,1`+ `+ `size.n < \@ e&
dup \; e&
1,
```
## Explanation
Prettified code:
```
.\n 0 \; .n e* .n `t
dup ( dup ( 1, ) e& ) `' `flat 1`, 0`, 1`+ `+
```
* `.\n 0 \; .n e*` store the input as *n*, push 0, execute the next line *n* times...
	+ `dup ( dup ( 1, ) e& ) `' `flat` top of stack with 1s replaced with `1 1`
	+ `1`, 0`, 1`+ `+` prepend `0 1`, append `1`, append result to existing sequence
[Answer]
# [Haskell](https://www.haskell.org), 43 bytes
```
f n=iterate(\x->x++'b':show x)"a"!!n!!n<'a'
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m708I7E4OzUnZ2W0km6Ec0CAUuxNu9zEzDwFW4WC0pLgkiIFFYWUfIVMBRtdhWgDPT1DA4NYa4XMNIU0oFhJRmqegpKhjoKSQmpOcaqCkgGQubS0JE3X4qZ2mkKebWZJalFiSapGTIWuXYW2tnqSulVxRn65QoWmUqKSomIeENmoJ6pDtCyAUlAaAA)
`f n` is the `n`th element of sequence #1, as either True or False.
The string built by `iterate` has the same "shape" as the real string:
```
ab"a"b"ab\"a\""b"ab\"a\"b\"ab\\\"a\\\"\""…
a,'a','a,''a''','a,''a'',''a,''''a'''''''…
```
`"\` both correspond to quotes, `ab` correspond to `a,`. So, we can use `char<'a'` to detect quotes.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
0;x‘Ø1jƲŻ$$¡ḣ
```
A monadic Link that accepts `n` and yields the first `n` terms of the boolean is-a-quote sequence.
**[Try it online!](https://tio.run/##ASEA3v9qZWxsef//MDt44oCYw5gxasayxbskJMKh4bij////MTI "Jelly – Try It Online")** Or see a longer prefix (by not heading) [here](https://tio.run/##AR0A4v9qZWxsef//MDt44oCYw5gxasayxbskJMKh////NA "Jelly – Try It Online").
### How?
Starts with a zero (the initial `a`) and builds up the sequence exactly as described in the question, using zeros for non-quotes and ones for quotes.
```
0;x‘Ø1jƲŻ$$¡ḣ - Link: integer, n
0             - set the left argument, x, to zero
           ¡  - repeat n times:
          $   -   last two links as a monad - f(x):
         $    -     last two links as a monad - g(x):
       Ʋ      -       last four links as a monad - h(x):   e.g. [0,0,1,0,1]
   ‘          -         increment                               [1,1,2,1,2]
  x           -         repeat (double the quotes)              [0,0,1,1,0,1,1]
    Ø1        -         [1,1]
      j       -         join (wrap in quotes)                   [1,0,0,1,1,0,1,1,1]
        Ż     -       prepend a zero (prepend a comma)          [0,1,0,0,1,1,0,1,1,1]
 ;            -     concatenate that to x
            ḣ - head to index n
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
;Ø.;x‘$;1
0Ç¡ḣ
```
[Try it online!](https://tio.run/##ASEA3v9qZWxsef//O8OYLjt44oCYJDsxCjDDh8Kh4bij////MTU "Jelly – Try It Online")
Full program yielding first \$n\$ elements of the quote/non-quote sequence. Exponentially slow; better tested with [manual control of the number of iterations](https://tio.run/##ASQA2/9qZWxsef//O8OYLjt44oCYJDsxCjDDh8aTwqHhuKP//zf/NjE).
```
;Ø.;x‘$;1    Monadic helper link: iterate
;Ø.          Append [0, 1].
   ;         Append
    x $      the argument with its elements repeated by
     ‘       themselves incremented.
       ;1    Append 1.
0Ç¡ḣ    Main link
 Ç¡     Repeat that n times
0       starting from 0,
   ḣ    and take the first n elements.
```
[Answer]
# Batch Script, 80 bytes
Outputs the first n elements of sequence 1,
```
CMD/VON/CSET s=0^&(FOR /L %%Q in (1,1,8)DO @SET s=!s!01!s:1=11!1)^&ECHO !s:~,%1!
```
so ie if file is called quote.bat
```
CALL quote.bat 5
```
gives you
```
00101
```
I hardcoded 8 iterations because that's the maximum amount before the string gets too big and CMD fails to parse it. So I'm not too sure if this answer counts, but I thought it would be neat to post it anyway.
Edit : minus a bunch of bytes thanks to Neil
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~52~~ 47 bytes
```
f=->n,r=?0{r[n]||f[n,r+"01#{r.gsub ?1,'11'}1"]}
```
[Try it online!](https://tio.run/##KypNqvz/P81W1y5Pp8jW3qC6KDovtqYmLRrI1VYyMFSuLtJLLy5NUrA31FE3NFSvNVSKrf1foKBhoKdnaGCgqZebWKChlqapZa/zHwA "Ruby – Try It Online")
Returns the nth element.
[Answer]
# [Python 3](https://docs.python.org/3/), ~~109~~, ~~71~~, ~~64~~, ~~63~~, 62 bytes
```
a=w='0'
while[print(end=w)]:w=f"01{a.replace('1','11')}1";a+=w
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P9G23FbdQJ2rPCMzJzW6oCgzr0QjNS/Ftlwz1qrcNk3JwLA6Ua8otSAnMTlVQ91QXUfd0FBds9ZQyTpR27b8/38A "Python 3 – Try It Online")
-45 thanks to [@Steffan](https://codegolf.stackexchange.com/users/92689/steffan)
-1 because of [this answer](https://codegolf.stackexchange.com/questions/250015/infinite-quote-escaping-sequence/250023#250023)
-1 thanks to [@AnttiP](https://codegolf.stackexchange.com/users/84290/anttip)
## Explanation (Outdated):
```
a=w="0"
```
Self-explanatory
```
while 1:
```
Repeat infinite times.
```
print(end=w+"0");
```
print w with 0. There's "0" because "0" is a comma.
```
w="1"+
```
w is "1" and...
```
a.replace("1","11")+
```
double the ones of a and...
```
"1";
```
one.
```
a="00"+w
```
Put two zeroes and w.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 29 bytes
```
Ｎθ≔0ηＷ›θＬη≔⁺⁺η0⪫11⪫⪪η1¦11η…ηθ
```
[Try it online!](https://tio.run/##LY3LCsMgEEX3/Qpx5YCFuM6qZFFaSgn0C6xIRrBqfLT066022QwznDP3KpRReWlrvbhQ8r28njqyFcbDKSWzOEYHygm2@4PGasLOUcvcFU5u2i0ZGQIA2e3ZlrQN5KS9AidXb1qKEHRfH8Ga/Mei405awNYxR@Mym77K6gl96NYKMNYqhnp82x8 "Charcoal – Try It Online") Link is to verbose version of code. Outputs the first `n` elements of sequence 1. Explanation:
```
Ｎθ
```
Input `n`.
```
≔0η
```
Start with a string of `0` instead of `a`.
```
Ｗ›θＬψ
```
Repeat until there are enough elements.
```
≔⁺⁺η0⪫11⪫⪪η1¦11η
```
Extend the string by appending its quotation, but use `0` instead of a comma and `1` instead of a quote.
```
…ηθ
```
Output the first `n` elements.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 14 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ÎFDX3:5šbJÀ«I£
```
Outputs the first \$n\$ items of the binary sequence as string.
[Try it online.](https://tio.run/##yy9OTMpM/f//cJ@bS4SxlenRhUlehxsOrfY8tPj/f0MDAwA)
**Explanation:**
```
Î              # Push 0 and the input
 F             # Pop and loop the input amount of times:
  D            #  Duplicate the current string
   X3:         #  Replace all 1 with 3
      5š       #  Convert the string to a list of digits, and prepend a 5
        b      #  Convert each digit to a binary string
               #  (3 become 11; 5 becomes 101; 0 and 1 remain unchanged)
         J     #  Join it back together to a single string
          À    #  Rotate it once towards the right, so the leading 1 is trailing
           «   #  Append it to the previous string we've duplicated
            I£ #  Only leave the first input amount of characters
               # (after the loop, the result is output implicitly)
```
[Answer]
# JavaScript (ES6), ~~50~~ 49 bytes
*Saved 1 byte thanks to @tsh*
Returns the \$n\$-th term of the binary sequence, 0-indexed, where `0`'s are encoded with `2`'s.
```
f=(n,s='2')=>s[n]||f(n,s+21+s.replace(/1/g,11)+1)
```
[Try it online!](https://tio.run/##FcxBCsMgEADAr3hzF@2mBno0kHeEUMSakGBX0VIo5O8mvc5hdvd11Zctf26cXqG1xQLramUv0Q514vk4lr@o3qhKJeTofIDOdKs2BpXB5hPXFAPFtMJERGMp7gePO870dhngqQWjsIO4HkTa08YgtZCI7QQ "JavaScript (Node.js) – Try It Online")
[Answer]
# [Bash](https://www.gnu.org/software/bash/), 61 bytes
```
for((a=0;${#a}<=$1;));do a+=01${a//1/11}1;done;echo ${a:$1:1}
```
[Try it online!](https://tio.run/##lVDBaoQwEL37FUOaQ0QWTemhu9m0hW2/YvWQxhFDiy6agiD5djtaLR56aWDe5D3ehMl7N309VV@N9a5toBIxjFPVdkIYnSk@3plw1lyqOFZlCybRmeSjSVOZShkkaQ0qtHULpJ64PMkwhahE@2k6hIMBHG5oPZZaZJCB3NWMcsW/tA03h9zd/jUT7/exNdoP7LRg@fB2nw/HC9UDg42@5sPjhcURRQBCgKMQwJ0ZBbH95PpSBKYgSdySSQR0vCaHC2whOJNfN3fFqveaiwoY9/T8MoS9J9oz0Jo6/rhunWv8YoPDE/Cegl13vvLnIuQNi@bQp28 "Bash – Try It Online")
Returns the \$0\$-based \$n^{\text{th}}\$ element of the binary sequence.
[Answer]
# [Haskell](https://www.haskell.org), 57 bytes
```
s>>=id
s=[0]:[0:1:[b|b<-a,c<-[0..b]]++[1]|a<-scanl1(++)s]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m708I7E4OzUnZ2W0km6Ec0CAUuzu3MTMPAVbhYKizLwSBRWFksTsVAVDAwMgM2ZpaUmarsVNy2I7O9vMFK5i22iDWKtoAytDq-ikmiQb3USdZBvdaAM9vaTYWG3taMPYmkQb3eLkxLwcQw1tbc3iWIgBC6AUlAYA)
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 27 bytes
```
{{∊⍵0 1(,⍨¨@(⍸⍵)⊢⍵)1}⍣⍵⊢,0}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/v7r6UUfXo96tBgqGGjqPelccWuGg8ah3B1BE81HXIhBlWPuodzGQAeTqGNT@f9Q39VHbBFK1Gf8HAA "APL (Dyalog Extended) – Try It Online")
]