[Question]
  [
# Challenge
Write a non-empty program/function `p` that, given a non-empty input string `s`, outputs the position of the **first occurrence** of each character of `s` in the source code of `p`. 
For example, if your program is
```
main() { cout << magic << cin }
^0   ^5   ^10  ^15  ^20  ^25
```
and it receives an input `abcd{`, the output should be
```
[1, x, 9, x, 7] (0-based)        [2, x, 10, x, 8] (1-based)
```
Here, `x` represents any output that is not a valid output for a character position (e.g., a negative number, `0` if you use 1-based indexing, `NaN`, `Inf`, the string `potato`, a number greater than your program's length, etc).
## Restrictions
Reading the source code is not allowed (like in a proper quine). The use of comments is allowed, but does count towards your score.
Input and output can be done in a reasonable format, but must be **unambiguous** (only additional delimiters, no `rand` stream and claiming that the answer is somewhere in there), **consistent** (e.g., the `x` from above should always be the same value) and **human-readable**; for example, a string or a character array. You can assume that the input is a string (or array) of printable ASCII characters; no need to handle the entire Unicode set.
---
### Custom code-page or non-printable ascii in your code?
If your language uses a custom code-page (Jelly, APL, etc), you must take that into account (so a program `€æÆ` must output `[1, x, 2]` for an input `€%æ`). Using only non-ASCII characters to output `-1` always (since the input is ASCII-only) is not a valid solution. You may assume that your program natively accepts your custom codepage, i.e., if your program has a method of converting a character `A` to an integer `65` (ASCII encoding), you may assume that it now converts the 65th character in your codepage to `65`.
---
Inspired on the following challenge: [Positional Awareness](https://codegolf.stackexchange.com/questions/104017/positional-awareness)
  
[Answer]
## Python2, 55 Bytes
```
a=" )dfi(+m,nprut.';";print map(('a="'+a).find,input())
```
Starts with a string that contains all the characters used in the code, and then search the indexes
[Answer]
# [Lenguage](http://esolangs.org/wiki/Lenguage), 56,623 bytes
Below is a hexdump of the first 256 bytes. The remaining bytes can be chosen arbitrarily.
```
0000000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f  ................
0000010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f  ................
0000020: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f   !"#$%&'()*+,-./
0000030: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f  0123456789:;<=>?
0000040: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f  @ABCDEFGHIJKLMNO
0000050: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f  PQRSTUVWXYZ[\]^_
0000060: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f  `abcdefghijklmno
0000070: 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f  pqrstuvwxyz{|}~.
0000080: 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f  ................
0000090: 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f  ................
00000a0: a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af  ................
00000b0: b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf  ................
00000c0: c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf  ................
00000d0: d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df  ................
00000e0: e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef  ................
00000f0: f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff  ................
```
Output is in bytes, as customary for brainfuck et al.
### How it works
This is a simple cat program, specifically `,[.,]`.
The source code contains all 256 byte values in order, so each byte's index in it matches its value.
[Answer]
# [Lenguage](https://esolangs.org/wiki/Lenguage), 1.22e7 bytes
Consists of `12263215` `NUL` bytes, *(Hex 0x00)*.
Outputs a `NUL` for every character that doesn't appear in the source.
> 
>  The ruse is that the input will never contain a `NUL`, so we always output the amount of `NUL`s that there are characters in the input.
> 
> 
> 
This translates to the following Brainfuck program
```
,[[-].,]
```
And with a breakdown...
```
,[[-].,]
,[    ,]    #Basic Input loop.
  [-]       #Zero out the cell.
     .      #Print it (A NUL).
```
*This just shows the sheer power of Lenguage as a golfing language. Fear it.*
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~10~~ 9 bytes
```
“ṾiÐ€Ɠv”v
```
[Try it online!](https://tio.run/nexus/jelly#@/@oYc7DnfsyD0941LTm2OSyRw1zy/7/V3cDCvtn@pc5AfmOZUHqAA "Jelly – TIO Nexus")
### How it works
```
“ṾiÐ€Ɠv”v  Main link. No arguments.
“ṾiÐ€Ɠv”   Set the left argument and the return value to s := 'ṾiÐ€Ɠv'.
        v  Execute the string s as a monadic Jelly program with argument s.
 Ṿ         Uneval; yield a string representation of s, i.e., r := '“ṾiÐ€Ɠv”'.
     Ɠ     Read one line from STDIN and evaluate it like Python would.
  iÐ€      Find the index of each character in the input in r.
      v    Eval the list of indices as a monadic Jelly program with argument s.
           Why?
             This is the shortest way to add the character 'v' to the string s,
             meaning that we can use r without having to append anything.
           What?
             The v atom vectorizes at depth 1 for its left argument, meaning that
             it acts on arrays of numbers and/or characters. When fed an array of
             integers, it first converts them to strings, then concatenates the
             strings and evaluates them as a Jelly program. For example, the array
             [1, 2, 3] gets cast to the string '123', then evaluates, yielding 123.
             Something slightly different happens if the array starts with a 0. For
             example, the array [0, 1, 2] gets cast to '012' just as before, but
             Jelly views '0' and '12' as two separate tokens; numeric literals
             cannot start with a 0. Since the Jelly program is monadic, the first
             token – '0' – sets the return value to 0. Since the second token –
             '12' – is also a niladic link, the previous return value is printed
             before changing the return value to 12. Then, the program finishes
             and the last return value is printed implicitly.
```
[Answer]
# pbrain, ~~402~~ ~~356~~ ~~340~~ ~~338~~ 329 bytes
```
[(:<>)+,-.](>>>>>>)+([-]<<[->+>+<<]>>[-<<+>>]>>[-<+<+>>]<[->+<]<[-<->]<)+([-]+++++++[>+++++++++++++<-]>)+([-]+++++[>++++++++<-]>)+(-:<+++[->++++++<]>)+(-:++)+(-:++)+(----:+)+(-:++)+(-:+)+(-:+)+(-:+)+([-]++:++)+([>[->+>+<<]>>[-<<+>>]<:>>+:[[-]>+<]>-[<<<<[-.>]>>>>>>+>>>>>]<<[-]<<+<-]>>>)[-]>>>>>>>,[<<<<<<++<+++++++++++++:>>>>>>,]
```
Phew, @KritixiLithos and I [have been working on this for 4 days now.](http://chat.stackexchange.com/rooms/50556/coding-bf)
Prints `0x00` if input char isn't in program, index of the char (1-based) in hex otherwise. [Try it online!](https://tio.run/nexus/bash#bZDBbsMwCIbvewrLmqZUBFu9eogXQT6krZf20CZKdqi07dkz7FhaWu0/AOYDC0jH82DsIk0g3kGLLjZctINGMBIJMjAQRWZBImBeIyhhwZQdob7WJlglDFsRRt7wP1oBBspprHmqSYCNUwV4SD/Z8vsKhf8ZnQIzBNGyPDajEOUVXV4qC4ota6spo@kpBCvmtjQoAXpYLlQcF8vjNPRTd31J@bR4M/Z1b8238cP46cfD1F1u1ZlaqfB@PxkcZ43mpFEydvbO@Tfje7ss3eF4kvj1E97TR38GbB3xLw)
### Explanation:
```
[(:<>)+,-.]
All chars listed here; like other submissions 
(>>>>>>)
@KritixiLithos added this part; I don't know what it does but saves the program
+([-]<<[->+>+<<]>>[-<<+>>]>>[-<+<+>>]<[->+<]<[-<->]<)
Comparison ;calculates z=x!=y and puts it in between x and y
Start; X _ _ _ Y
           ^
End;   X Z _ _ Y
         ^
+([-]+++++++[>+++++++++++++<-]>)
Function to add 91 to the tape
+([-]+++++[>++++++++<-]>)
Function to add 40 to the tape
+(-:<+++[->++++++<]>)
Function to add 58 to the tape
+(-:++)
Function to add 60 to the tape
+(-:++)
Function to add 62 to the tape
+(----:+)
Function to add 41 to the tape
+(-:++)
Function to add 43 to the tape
+(-:+)
Function to add 44 to the tape
+(-:+)
Function to add 45 to the tape
+(-:+)
Function to add 46 to the tape
+([-]++:++)
Function to add 93 to the tape
+([>[->+>+<<]>>[-<<+>>]<:>>+:[[-]>+<]>-[<‌​<<<[-.>]>>>>>>+>>>>>]<<[-]<<+<-]>>>)
```
This last function is the loop. It loops through the selected characters `[(:<>)+,-.]` in order and compares the input with the character. Now I'm going to give a deeper explanation on how this loop works.
```
12-n n+2 _ n+2: _ _ _ i _ _ _ _ _ _;  n=loop counter
                  ^                ;  i=input
```
The stack looks like that while in a loop. The loop will run until `12-n` is `0`. Then we have the counter which is `n+2`. This counter is also the number of the function for each of the selected characters. So when `n=0`, `n+2` will be corresponding to the first character, ie `[`. `>[->+>+<<]>>[-<<+>>]<:` does just that, it converts the counter to the character.
Once the pointer is where the caret is, we will compare the character produced from the counter variable with the input while preserving them.
```
12-n n+2 _ n+2: Z _ _ i _ _ _ _ _ _;  n=loop counter
                ^                  ;  i=input
```
`Z` is `0` when the character is equal to the input, or some other non-zero integer otherwise.
Now we come up with an if-statement to check this equality.
```
[[-]>+<]
```
If `Z` is non-zero, ie the character and the input are *not* the same, we increment the next memory place.
After we come out of this if-statement, we decrement the next memory place. Now this memory place contains `!Z`. Finally using this, we output the index of the character if it matches with the input and then exit the loop forcibly. Else, we continue on with the loop until either it is over or a match is found.
```
[-]>>>>>>>
Clears first byte; goes to position to start program
,[<<<<<<++<+++++++++++++:>>>>>>,]
Loops inputs
```
[Answer]
## [CJam](https://sourceforge.net/p/cjam), ~~14~~ 12 bytes
```
{sq\f#p_~}_~
```
Uses 0-based indexing and `-1` for characters that don't appear in the source.
[Try it online!](https://tio.run/nexus/cjam#@19dXBiTplwQX1cbX/f/f2JSYUGackxxNZAHAA "CJam – TIO Nexus")
[Answer]
# Javascript, 34 bytes
```
f=a=>a.map(v=>('f='+f).indexOf(v))
```
It takes input as array of strings, `x` is `-1` (0-based indexing).
[Answer]
# C, ~~153~~ ~~152~~ 143 bytes
```
char s[99],p[]="odeflnrti%()*+-0;<={}\\";c;f(char*i){sprintf(s,"char s[99],p[]=\"%s",p);for(c=0;c<strlen(i);)printf("%d ",strchr(s,i[c++])-s);}
```
[Try it online!](https://tio.run/nexus/c-gcc#XYxBCoMwEADvfYUsBLIawausviTmkG4MBmyUxJv4dk2hp16Hmbl5sanKuu@N2rUZYXOzX2M6gpBYN21Hw3he0wTE5OVXrgOeeU8hHl5mBX/9BCKD2pH8liSPHfGQj7TOUQYk/GUgXAWqcF5SeQTNTWOwzUjX62NDlHgWyb7ZaSjsvh8 "C (gcc) – TIO Nexus")
[Answer]
## Ruby, ~~41 88 86 71 69 67 61~~ 56 bytes
```
a='p$<.chrs{| #index};"';$<.chars{|c|p"a='#{a}".index c}
```
Thx Lynn for killing 6 bytes
[Answer]
# ><> (Fish) 70 bytes
```
 #.0+4*a5;!?l|!?f4*b+l1--naolc3*1+0.01?!|~ed+0.0+2e-{:;!?+1:i-1:r}+2:"
```
Probably the longest ><> 1 liner I've ever made.
It will print the output for each character found on a separate line (0 indexed).
A non found character will always print the length of the code + 1 (I could change this if deemed not okay in it's current state) so in this case 71 will always be the "Not found" characters.
I'll run up an explanation once I get the time.
Some test cases;
##K = 1\n1\n71
#"# = 1\n69\n1
[Try it online](http://fish.tryitonline.net/#code=ICMuMCs0KmE1OyE_bHwhP2Y0KmIrbDEtLW5hb2xjMyoxKzAuMDE_IXx-ZWQrMC4wKzJlLXs6OyE_KzE6aS0xOnJ9KzI6Ig&input=IyIj)
[><> language](https://fishlanguage.com/playground/TQT63MZyBDuhgn3To)
[Answer]
# [Perl 6](http://perl6.org/), ~~50~~ 52 bytes
```
{(('R~.index$_) for}\\'R~'{((\'').index($_) for $_)}
```
Translation of [G B's Ruby solution](https://codegolf.stackexchange.com/a/104178/14880) and [Rod's Python solution](https://codegolf.stackexchange.com/a/104184/14880).
A lambda that inputs a list of characters and outputs a list of zero-based indexes (`Nil` for nonexistent characters).
*EDIT: Fixed an oversight - required adding 2 bytes :(*
[Answer]
## Clojure, ~~43~~ ~~56~~ 48 bytes
Edit: Damn I forgot about `2`! Increased from 43 to 56.
Edit 2: Updated the sample code below this text, updated the number of bytes not to include `(def f ...`) but just the hash-map part.
```
{\{ 0\\   1\  3\0   4\1 10\3 14\4 20\2 34 \} 43}
```
The hash-map consists only of characters `01234{\\}`, and it encodes their locations. In Clojure hash-maps can be used functions, as shown in this complete example (`f` could be replaced by the hash-map definition):
```
; Keeping track of the zero-based index:
;      00000000001111111111222222222233333333334444444444
;      01234567890123456789012345678901234567890123456789
(def f {\{ 0\\   1\  3\0   4\1 10\3 14\4 20\2 34 \} 43})
(map f "0123456789{} \\abcdef") ; (4 10 34 14 20 nil nil nil nil nil 0 43 3 1 nil nil nil nil nil nil)
(apply str (keys f))            ; " 01234{\\}"
```
I guess this counts :)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 19 bytes
```
"'ìsvDyk,"'"ìsvDyk,
```
[Try it online!](https://tio.run/##MzBNTDJM/f9fSf3wmuIyl8psHSV1JRjz//9odSV1HQX1YhBhDCJMQMTh5WByDYgsAxEuIKISRGSDCB0goRScn5takpGZl66QmFRcWpSipxQLAA "05AB1E – Try It Online")
This outputs -1 in place of missing chars.
---
Luis Mendo posted this (slightly modified) on [Golf you a quine for great good!](https://codegolf.stackexchange.com/questions/69/golf-you-a-quine-for-great-good/97458#97458) , adding "s" and "k" to that quine results in this answer as well. However, I can't take credit for that trivial of a modification... Luis, you can message me if you'd like to repost this and I'll just delete it. If you want to see my progress before finding that question, view edits. Well... It ***was*** significantly like his at one point.
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2), 10 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
"Ṙs€Ȯ"Ṙs€Ȯ
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728JKM0Ly_faMGCpaUlaboWW5Qe7pxR_KhpzYl1CNaS4qTkYqiCBUuKI06sg7AB)
#### Explanation
```
"Ṙs€Ȯ"Ṙs€Ȯ  # Implicit input
"Ṙs€Ȯ"      # Push the string "Ṙs€Ȯ"
      Ṙ     # Surround it by quotes
       s€Ȯ  # Get the index of each character
            # of the input in the string
            # Implicit output
```
[Answer]
# JavaScript, 39 bytes
```
p=s=>[...s].map(c=>`p=${p}`.indexOf(c))
console.log( p('mapP') )
```
[Answer]
# Pyth, 11 bytes
```
xL_+N"N+_Lx
```
A program that takes input of a `"quoted string"`, with any quotes in the string escaped with a preceding `\`, and prints a list of zero-indexed values with `-1` for characters not in the source.
[Try it online!](https://tio.run/nexus/pyth#@1/hE6/tp@SnHe9T8f@/UmJSvE@MkrZfRYQSAA "Pyth – TIO Nexus")
**How it works**
```
xL_+N"N+_Lx    Program. Input: Q
xL_+N"N+_Lx"Q  Implicit quote closure and implicit input
     "N+_Lx"   Yield the string "N+_Lx"
   +N          Prepend a quote
  _            Reverse
 L          Q  Map over Q:
x               Yield the index of the character in the string
               Implicitly print
```
[Answer]
# SmileBASIC, ~~128~~ ~~96~~ ~~88~~ 86 bytes
```
?R<3+CD,4LINPUT(S$)WHILE""<S$?INSTR("?R<3+CD,4LINPUT(S$)WHILE"+CHR$(34),SHIFT(S$))WEND
```
An important thing to realize is that this is not *really* a quine challenge. You only need the source code up to the **last unique character**.
I put at least 1 of each character at the beginning of the code: `?R<3+CD,4LINPUT(S$)WHILE"` so I only have to store a copy of the program up to the first quotation mark.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-m`](https://codegolf.meta.stackexchange.com/a/14339/), 2 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Takes input as a character array. Output is 0-based, using `-1` for invalid characters. String input *could* also be used but there would be no separator between the output indices, which shouldn't be an issue as it would be unambiguous seeing as they can only be `0` & `-1`.
```
bb
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LW0&code=YmI&input=WyJiIiAiYSJd)
```
bb     :Implicit map of each U in input array/string
b      :First 0-based index in U of
 b     :  Literal "b"
```
Alternatively:
```
aa
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LW0&code=YWE&input=WyJiIiAiYSJd)
`a` being `lastIndexOf`.
[Answer]
# Java 8, ~~172~~ ~~122~~ 119 bytes
```
a->/*.forEch(Systemupin"\dxO)+ ;:*/a.forEach(c->System.out.print("a->/*.forEch(Systemupin\"\\dxO)+ ;:".indexOf(c)+" "))
```
0-indexed, and gives `-1` for characters that aren't part of the source code.
[Try it online.](https://tio.run/##jZJbT8IwGIbv@RVNrzYIxfOJSOIBFRVQ59l6UbqOFbZurh2Cht8@yzYlwxBN2qRf@/bt873pgIxINQiZGNjDhHpEStAmXHyWAOBCscghlIHOrARgFHAbUGOgr6BYcQ9JFTHio5ZQVroCxKxr5VRPPaQiilPQAQLsg4RUG7UycoKoSV3DmkjF/DjkAmJ73DUroL5XrpH0mOhzWm1kEhTECoWRRjHgEgcM8Y8HRFzYbNx1DGpWIICmmdQzmDDueRomZ0o78XWfhgbnov/ySsysR8Xk/576CxcvNcEzm7kRLkBjCLDGhmmQ3zhBsSTFEsOFGi/Ie9RmTt/lg6HniyB8i6SKR@/jyUdRd3B4dNw8OT1rnV9ctjvdq@sb6/bu/uHx6bmoW1ldW9/Y3Nre2S3uW27/98N5J9PS/EOk4aeKLHwg8@wFooZE1CWRNMzcaTFXTxi54TT5Ag)
**Explanation:**
```
a->                    // Method with character-array parameter and no return-type
  /*.forEch(Systemupin"\dxO)+ ;:*/
                       //  Comment containing the remaining characters of the code
  a.forEach(c->        //  Loop over the input-array:
    System.out.print(  //   Print
      "a->/*.forEch(Systemupin\"\\dxO)+ ;:"
                       //   from a String containing all the characters used in the code
      .indexOf(c)+" "))//   the index of the char, plus a space as delimiter
```
[Answer]
# Python, ~~90~~ 88 bytes
```
a,b,d=" ()+.7:[]efilmnor","a,b,d=\"",lambda e:[[b.find(d),a.find(d)+7][d in a]for d in e]
```
Test case:
```
print(d("a,b(]q"))
#[0, 1, 2, 8, 15, -1]
```
[Answer]
# [Stacked](https://github.com/ConorOBrien-Foxx/stacked), noncompeting, 36 bytes
When I said this language was still in development, I meant it. Apparently, `prompt` used to consume the entire stack. This is why I can't have nice things. [Try it here!](https://conorobrien-foxx.github.io/stacked/stacked.html)
```
[tostr ':!' + prompt CS index out]:!
```
This is the standard quine framework. Basically, `:` duplicates the function `[...]` on the stack, which is then executed with `!`. Then, the inside of `[...]` executes with the function on the stack. It casts it to a string, appends `:!` (the program itself), then takes a string input with `prompt`. `CS` converts it to a character string. A character string is a bit different from a regular string in that it has operators vectorize over it. In this case, `index` vectorizes over the input, yielding each index of the input string in the program, finally being `out`putted.
For input `Hello, World!`, this gives:
```
(-1 27 -1 -1 2 -1 6 -1 2 5 -1 26 9)
```
I tried using the one without a quine (i.e. encoding the string of characters that appear in your source), but there is only one type of quotation mark in Stacked, namely, `'`, so it would be longer to do that type of solution.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 12 bytes
```
m€`:'""m€`:'
```
[Try it online!](https://tio.run/##yygtzv7/P/dR05oEK3UlJSjjP1woRiktPz8mBgA "Husk – Try It Online")
### Explanation
The explanation is using `¨` to delimit strings and `'` to delimit characters:
```
m€`:'""m€`:'  -- implicit input, for example: ¨m"a1`¨
      "m€`:'  -- string literal: ¨m€`:'¨
  `:'"        -- append character '"': ¨m€`:'"¨
m             -- map function over each character (example with 'a'):
 €            -- | index of first occurrence (1-indexed): 0
              -- : [1,6,0,0,3]
```
[Answer]
# [J](http://jsoftware.com/), ~~31~~ 22 bytes
```
11|1+i.~&'11|1+i.~&'''
```
[Try it online!](https://tio.run/##y/r/389JT@FR22RDBRBpqgCmDA0glCmYMjLgSrPVUzA0rDHUztSrU1NHsNTV/6cmZ@QrpCkUl6Rk5ikY/gfKahsqZ6rr1QEA)
1-indexed, 0 for characters that aren’t present in the code. `''` stands for a single quote. Find each character in the string `11|1+i.~&'`, add 1, modulo 11.
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 31 bytes
```
'rd3*i:0(?;}{:}-&b0&?.75*l-nao]
```
[Try it online!](https://tio.run/##S8sszvj/X70oxVgr08pAw966ttqqVlctyUDNXs/cVCtHNy8xP5aggri4OAA "><> – Try It Online")
Output is 1-indexed, with `32` meaning the character is not in the code. 
[Answer]
## [Perl 5](https://www.perl.org/) with `-pl`, 43 bytes
Uses newline separated input and prints `-1` for characters not appearing in the program.
```
$s=q{$_=index"\$s=q{$s};eval\$s",$_};eval$s
```
[Try it online!](https://tio.run/##K0gtyjH9X1qcqlCeWJSXmZdebP1fpdi2sFol3jYzLyW1QikGwi2utU4tS8wB8pR0VOIhHJXi//9juFK5yrgSuXK4VP/lF5Rk5ucV/9ctyFHQ9TXVMzA0AAA "Perl 5 – Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 19 bytes
```
"'sym[]I+"'"s+ym[]I
```
[Run and debug it](https://staxlang.xyz/#c=%22%27sym[]I%2B%22%27%22s%2Bym[]I&i=y%5E%27%22Bs&a=1)
Outputs 0-based index, one character per line. Turns out it's shorter than modifying the `"34bL"34bL` quine I wrote earlier.
[Answer]
# SAS, 124 ~~60~~ bytes;
The new answer is shift from pure SAS 4GL to SAS macrolanguage.
The code:
```
%let S=%nrstr(%macro _(t);data;s=&t;do i=1to length(s);p=find(symget("S"),char(s,i));put p@;end;run;%mend;%_);%unquote(&S())
```
To run it, insert your `'string'` enclosed in single quotes between brackets after `&S`, for example:
```
...%unquote(&S('!#&%macro _sS@'))
```
and in the log you will see:
```
0 0 20 1 2 3 4 5 6 7 8 18 57 77
```
To escape single quote in the string write it doubled: `'AB''CD'`.
---
[EDIT:]
60 bytes answer was suggested for rejection as "a snippet, meaning it cannot just assume variables are defined". In context of SAS 4GL programming I agree to disagree with that opinion. ;-)
I keep it below for further comments.
---
Code assume that the string is given in a variable `s` and the source code is stored in macroVariable `s`.
The code:
```
do i=1to length(s);p=find(symget("S"),char(s,i));put p@;end;
```
Process goes as follows:
1. store source code in macrovariable `S` by runing:
```
data _null_;
  call symputX("S",'do i=1to length(s);p=find(symget("S"),char(s,i));put p@;end;',"G");
run;
```
2. assign string `"i S;abcd{"` to variable `s` and resolve ( by `&S.` ) the macrovariable `S`:
```
data;
s="i S;abcd{";
&S.
run;
```
The Log says:
```
1    data _null_;
2    call symputX("S",'do i=1to length(s);p=find(symget("S"),char(s,i));put p@
2  ! ;end;',"G");
3    run;
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
4
5    data;
6    s="i S;abcd{";
7    &S.
8    run;
4 3 35 19 41 0 39 1 0
NOTE: The data set WORK.DATA14 has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
```
You can run:
```
%put %length(%superq(S));
```
to get source code length.
[Answer]
# JavaScript, ~~59~~ 57 bytes
-2 Bytes thanks to [Shaggy](https://codegolf.stackexchange.com/users/58974/shaggy)
```
a=>(m='Opined.fx,"+)',a.map(x=>("a=>(m='"+m).indexOf(x)))
```
Without reading source.
[Attempt This Online!](https://ato.pxeger.com/run?1=bVLLctMwFJ1hma-4DQFJxDFJaekjOKElKZRHwqOFQhpqociJwC9suRiCWfEXbLKALf8DX4NsOc10htWVj86959xj_fjpBxO--M0CP5bA1BkssH8l0mls_9mhVgd7FhqGwucT00mNap0gg5oeDXGq7qoloVr3iCn8CU-HDk4JIXrA3yvfbVNGwsOkXanwc-pi5FgI6oVQjmnZw0Gvf6J0m-0SGAyPzg6Gx4OeAhutCx6NmRAKQrBWvVq7dv0UYXKjbjTMm83W-q2Nzdtb2zu77TtWp2vv7d_r9Q_uPzh8-Ojxk8Hw6bPnL46OX746ef1m9G389uwufccm3JnOxPsPrucH4ccolsn5p_Tzl_nXDJlx6AqJEVp55GnImVTihYkiAQZWB-YVAM0oehQh360cwFQ_QMRlEvmAWgiEX9K6uo6aY9Pl_lTOVCg6ht3V9u1KtjJAmUyoq-Y7uLBAlmGFNI7zn1aba0pmg2UV39pzZmtm4HLTDaYYFw1dQKfJ-lZzEynF4rjBEDEjHnIqcatJcmXhAF7L6aRc2wmiPmUzjJkBglzeP385WnEkxu0LmOaZFcYuwWEOK6PAl9jSX_h_bwbYYRALKQIfAgdqc5aBiFXlmW1A0ZTTbTwNpEJpRmyiA9SPcbHQ9R8)
[Answer]
# [Burlesque](https://github.com/FMNSSun/Burlesque), 27 bytes
```
#Qup~-"#Q"j?+wd\[Ppm{pPjFi}
```
[Try it online!](https://tio.run/##SyotykktLixN/f9fObC0oE5XSTlQKcteuzwlJjqgILe6ICDLLbP2/38A "Burlesque – Try It Online")
Returns list of indices with `-1` for each not present.
```
#Q      #Push remaining code to stack
up      #Turn to string
~-      #Remove brackets
"#Q"j?+ #Add the "#Q" to the beginning
wd\[    #Remove all spaces
Pp      #Push to virtual stack
m{      #Map (apply to each char in input)
  pP    #Pop from other stack
  jFi}  #Find character in string
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~49~~ 48 bytes
-1 byte thanks to Jo King
```
c='print map(("c=%r;ex"%c).find,input())';exec c
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9lWvaAoM69EITexQENDKdlWtcg6tUJJNVlTLy0zL0UnM6@gtERDU1MdKJqarJD8/78SqpYYmJ4Y3JrylQA "Python 2 – Try It Online")
---
# [Python 3](https://docs.python.org/3/), ~~53~~ ~~52~~ 51 bytes
-1 byte thanks to Jo King
```
c='print(*map(("c=%r;ex"%c).find,input()))';exec(c)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P9lWvaAoM69EQys3sUBDQynZVrXIOrVCSTVZUy8tMy9FJzOvoLREQ1NTUx0onJqskaxJlqZ8AA "Python 3 – Try It Online")
]