g | x | w | all
Bytes Lang Time Link
011AWK250730T003122Zxrs
015sed n250729T214843ZJan Blum
063C++ gcc250704T132914Zjdt
022Google Sheets250628T142755Zdoubleun
085Bespoke250728T075528ZJosiah W
009GolfScript250728T061939ZErikDaPa
011Pip250724T171210ZDLosc
100C64 Basic250724T170821ZOSI8
044Scratch250629T150609ZRhaixer
042Nim250724T080554ZjanAkali
008APL+WIN250628T144851ZGraham
002Japt250630T120218ZShaggy
017Alice250714T092509ZJulian
014Perl 5250709T215129ZXcali
2692Lenguage250714T051417ZATaco
022Dart250708T083747Zlrn
086brainfuck250705T131849Zmatteo_c
046Maple250630T203800Zdharr
027Bash250701T181446Zwobtax
043Tcl250629T165841Zsergiol
050PHP250701T152236Zmbomb007
064C#250701T132435ZThomas W
016Ruby n250630T211128ZG B
01105AB1E legacy250701T050954ZLucenapo
034Tcl250630T203810Zsergiol
037C gcc250630T014459ZAShelly
015X86 Assembly nasm250630T164727ZAShelly
026PowerShell Windows and Core250630T113659Zuser3141
004Vyxal250628T141235Zlyxal
037Ruby250630T092449ZRamzis
022JavaScript Node.js250628T144026Zl4m2
010Haskell + hgl250629T155729ZWheat Wi
022JavaScript Node.js250629T123347ZSteve Be
008Vyxal 3250629T014131ZThemooni
056><> Fish250628T203146Zmousetai
020Zsh250628T142803Zpxeger
017Python250628T144801ZJonathan
010TinyAPL beta 0.13.0250628T145836ZRubenVer
004Jelly250628T142234ZJonathan
001Retina 0.8.2250628T143414ZNeil
006Uiua 0.17.0dev.1250628T142421ZTbw
031Python250628T140957ZYurichBR

AWK, 11 bytes

/[[\]\/\\]/

Attempt This Online!

Returns the char if match, or nothing if no match.

sed -n, 15 bytes

/[]\[\\\/q1]/q1

Try it online!

Reads from standard input, exit code 1 if contained in the source, 0 otherwise.

C++ (gcc), 65 63 bytes

[](int*i){*i=0;for(int t:" \"*()01:;=[]forint{|}")*i|=t==i[1];}

Try it online!

Google Sheets, 24 22 bytes

=bul(A1,"=bul(A1,"")")

Put the character in cell A1 and the formula in B1. Gets the 1-indexed first occurrence of the character in the code, or an error value if it's not present.

Google Sheets supports international function names, and bul() is find() in Turkish. It is a valid function name in any locale, and will get automatically translated to the spreadsheet locale if it's not Turkish, and will continue to work after translation. To avoid translation, set File > Settings > Locale > Türkiye.

In an English locale, you can get the equivalent like this (24 bytes):

=find(A1,"=find(A1,"")")

A variation of =find(A1,formulatext(B1)) would work too, and there are shorter names for those functions in other languages, but that would violate rules.

Bespoke, 85 bytes

AAAAA@AA@AAAA@AA@AAAAAAAA@AAAAAAAAAA@AAA@AA@AAA@AA@AAAAAAAA@AAAAA@AAAAAAAA@A@AAAAAA@A

Equivalent to the following code (in "mnemonic" form):

INPUT CH
PUSH BI STACKTOP QUOTIENTOF
PUT XX:TRI BI;STACKTOP MINUS
STACKTOP F
OUTPUT N

GolfScript, 9 bytes

"\\\"?"\?

Output: Truthy if not negative, else falsy

Try this online!

Pip, 11 bytes

{}(); aNSTf

Outputs 0 for "does not contain" or a positive number for "does contain." Attempt This Online!

Explanation

{}(); aNSTf
          f  Main function
        ST   Stringify
      aN     Count occurrences of command-line argument in that string
{}();        The stringification adds these characters, so they need to be added
             to the code as some no-ops

Questionable but interesting 10-byte solution

aQ_MRXWSTf

Attempt This Online!

Outputs 0000000000 for "does not contain" or a string of nine 0s and one 1 for "does contain." Technically, if these were treated as strings in Pip, all-zeroes would be falsey and not-all-zeroes would be truthy. However, behind the scenes, they're actually lists, which would all be considered truthy, so I don't think this output method quite passes muster. It could be fixed by adding _MS at the beginning, but that's longer than my main solution.

Explanation

aQ_MRXWSTf
       STf  Stringify main function
   MR       Find every regex match of
     XW       Word character (letter/number/underscore)
   MR       and map this function to it:
aQ_           Is it equal to the command-line argument?

In other words, filter out all the extra characters added during stringification before checking if the program argument is in the result.

C64 Basic, 100 bytes

The output indicates the position of the searched character within the source code, otherwise it is 0.

C64 screenshot

Try in emulator

Scratch, 44 bytes

Note: neither of these check for newlines because I have no idea how you would feed them one.

define(f
say<[yti\[doscn\]\\<afe(]contains(f

enter image description here

Full program version, 80 bytes

when gf clicked
ask()and wait
say<[an\[\]hfi\\\(wd\<rstloek\)ycg]contains(answer

enter image description here

Nim, 42 bytes

proc(p='p'):bool=p in'"'&"proc():=bl in'&"

Try it online!

APL+WIN, 12 8 bytes.

-4 bytes thanks to Adam

Prompts for input character. 1 if it exists in src code 0 if not.

⎕∊'∊⎕'''

Try it online! Thanks to Dyalog Classic

Japt, 2 bytes

Simply checks if the input contains the character ø.

øø

Try it

Alice, 17 bytes

' wt.0g!].$KI(?O@

Try it online!

Takes the searched character as input. Prints to stdout the character if found or nothing otherwise.

' wt.0g!].$KI(?O@­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁤⁣‏‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁤⁤‏⁠‎⁡⁠⁢⁡⁡‏‏​⁡⁠⁡‌­
'                  # ‎⁡Pushes 32, the ascii code of the space char
  wt     .$K       # ‎⁢For each `i` between 32 to 0
    .0g            # ‎⁣Pushes the character at position (`i`, 0) in the source code as its ascii code
       !]          # ‎⁤Pops, writes it to the tape an shift the tape right
            I(     # ‎⁢⁡Reads an argument from the input and search it on the tape
              ?    # ‎⁢⁢Read the tape at the current position and pushes the value
               O@  # ‎⁢⁣Print to stdout if found then exit
💎

Created with the help of Luminespire.

Alice, 28 bytes without source reading

'"''"w!]d$KI(?O@"w!]d$KI(?O@

Try it online!

Perl 5, 14 bytes

$_=y;\;y$_=\\;

Try it online!

Lenguage, 2692 bytes

This program consists of every byte from 0 - 255 repeated for 2692 bytes. As this is too long for an answer, a snippit of the code can be seen below:

          00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000   00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  ................
00000010   10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F  ................
00000020   20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F   !"#$%&'()*+,-./
00000030   30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F  0123456789:;<=>?
00000040   40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F  @ABCDEFGHIJKLMNO
00000050   50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F  PQRSTUVWXYZ[\]^_
00000060   60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F  `abcdefghijklmno
00000070   70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F  pqrstuvwxyz{|}~
00000080   80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F  €‚ƒ„…†‡ˆ‰Š‹ŒŽ
00000090   90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F  ‘’“”•–—˜™š›œžŸ
000000A0   A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF   ¡¢£¤¥¦§¨©ª«¬­®¯
000000B0   B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF  °±²³´µ¶·¸¹º»¼½¾¿
000000C0   C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF  ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
000000D0   D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF  ÐÑÒÓÔÕÖרÙÚÛÜÝÞß
000000E0   E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF  àáâãäåæçèéêëìíîï
000000F0   F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF  ðñòóôõö÷øùúûüýþ.

This program is equivilent to the BrainFuck code ,>+., which reads a byte, ignores it, and outputs 0x01 as every possible input byte is contained within this source code.

Try it online!

Dart, 22 bytes

Unnamed function returning true if passes a single-character string which occurs in its source, and false if the character doesn't occur in the source.

'contains.\'\\'.contains

Usage:

print('contains.\'\\'.contains('a')); // true
print('contains.\'\\'.contains('#')); // false

Annoying to have to escape the quote and then include the backslash too. A same-length alternative is 'contains."'"'".contains, which then has to include " in the characters.

As a named reusable function, it could be:

var c='vr =contains.;\'\\'.contains;

bringing it to 34 bytes (adding two occurrences of vr =; and one extra c and a).

brainfuck, 86 bytes

>,>+++++[<------>-]<<<++++[->>------------<++++[->->+<[>-]>[->>+<]<<<]<]>>>>>.;=KLMN\^

Try it online!

Maple, 46 bytes

c->evalb(c in[";",seq(String(op(procname)))]);

op(procname) captures all the code except the final semicolon; hence the added ";" in the list.

Bash, 27 bytes

[[ "'"'" []=*$1' == *$1* ]]

Try it online!

Takes one character as an argument, e.g., thisscript.sh '{'. Return value is the output: 0 for true, 1 for false.

Tcl, 43 bytes

puts [regexp $argv [read [open [info sc]]]]

Try it online!

Program which takes an argument via command line.

PHP, 50 bytes

<?php fn($s)=>strpos('<?ph fn($s)=>tro\',;\\',$s);

Run online here

The code is an anonymous function that takes the character as a string. The result is false if not contained, or an integer (the index of the first occurrence in the deduplicated code string) if contained.

C#, 64 bytes

I'd like to see some "normal" languages too.

C#, top level statements enabled. The character must be given as command line argument. The output is True or False.

Console.WriteLine("Consle.WritL(\"\\ag[0]);".Contains(args[0]));

Ruby -n, 22 16 bytes

p~/[p\\\/\]\[~]/

Try it online!

Thanks Value Ink as usual for -3 bytes

05AB1E (legacy), 11 bytes

"I'+å"'"+Iå

Try it online!

Tcl, 34 bytes

proc C c {regexp $c [info body C]}

Try it online!

This only scans the part between the {}. Is my answer valid?

C (gcc), 45 37 bytes

Trying it a "normal" language:

s(s){return strstr("s(){retun ,&;}\\\"",&s);}

Try it online!

Edit:

Kevin Cruijssen found:

s(s){s=strstr("s({=tr\"\\,&);}",&s);}

X86 Assembly (nasm), 15 bytes

bf 00 00 00 00 66 b9 0f 00 f2 ae 0f 94 c0 c3

Function that scans its own bytecode for the byte in AL, returns 1/0 in AL.

decompiled:

find_matches:
    mov edi, find_matches    ; EDI = address of self
    mov cx, 15               ; ECX = string length
    repne scasb              ; scan for AL
    setz al                  ; return 1 or 0
    ret

Try it online!

PowerShell (Windows and Core), 26 bytes

'''|% *ns$arg'|% *ns $args

Try it online!

Another 'normal' language, I guess.
A string with the characters used is passed to % (alias for ForEach-Object), which invokes the string's member "Contains()" (the only member matching *ns) for the argument.

Vyxal, 4 bytes

‛‛↔↔

Try it Online!

Outputs an empty string for truthy, a non-empty string for falsey.

Or, if you want total nonsense:

Vyxal O, 0 bytes


Try it Online!

Outputs nothing if the character isn't in the program.

Ruby, 37 bytes

p File.read(__FILE__).include?ARGV[0]

Try it online!

JavaScript (Node.js), 22 bytes

f=x=>(f+f).includes(x)

Try it online!

-2B Steve Bennett

f= both appear in function, so no need extra

JavaScript (Node.js), 24 bytes, assuming ascii input

A=B=>B<":"?"#;@ !">B:B<A

Try it online!

Worse than former solution but fun to keep

Haskell + hgl, 10 bytes

fe"fe\"\\"

Attempt This Online!

Explanation

fe checks if the second argument is an element of the first. "fe\"\\" is the string of all characters in the program.

An honorable mention to these 12 byte programs, which are longer but a bit more fun:

fe$sh"fe$sh"

Attempt This Online!

e/$sh"e/$sh"

Attempt This Online!

These one uses sh to enclose the string in quotes so that we don't have to use a backslash to escape the quote and then a backslash to escape the backslash.

Reflection

I've been saying for a long while that I should swap the names of e and fe, since fe is undoubtedly the more commonly used one. This would save 2 bytes on both versions of the answer.

Other than that I think this is as short as hgl is reasonably going to go on this particular task.

JavaScript (Node.js), 22 bytes

f=x=>(f+f).includes(x)

Try it online!

JavaScript (V8), 29 bytes

t=>/[=>/[\]\\.tes()]/.test(t)

Try it online!

Vyxal 3, 8 bytes

"q$c"q$c

Vyxal It Online!

"q$c"q$c­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌­
"q$c"     # ‎⁡literal string
     q    # ‎⁢quoted
      $c  # ‎⁣contains implicit input?
💎

Created with the help of Luminespire.

<script type="vyxal3">
"q$c"q$c
</script>
<script>
    args=[["\""],["$"],["c"],["a"],["%"],["P"]]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>

less fun:
Vyxal 3, 4 bytes

ᏜᏜ∩∩

outputs empty string for falsey and the character if truthy

Vyxal It Online!

ᏜᏜ∩∩­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁤‏‏​⁡⁠⁡‌­
ᏜᏜ∩   # ‎⁡two character string "Ꮬ∩"
   ∩  # ‎⁢intersection of this string and implicit input
💎

Created with the help of Luminespire.

><> (Fish), 56 bytes

i:::::::"i"=}":"=}'"'=}"'"=}"}"=}"*"=}"n"=}";"=+++++++n;

Try it

For each character, save in the stack if they are equal. Then add all the qualities up and print them.

Contains the following characters:

i, :, ', ", =, }, +, n, ;

Zsh, 20 bytes

grep "[-grep \"Z-^]"

Attempt This Online!

Input via stdin, outputs via exit code: 0 for yes, 1 for no.

Zsh, 0 bytes

Attempt This Online!

I'm guessing you didn't intend to permit empty solutions (standard rules would forbid it), but this follows your rules. Input is ignored, output is via exit code (0 for no, 1 for yes).

Python, 17 bytes

'\.count\''.count

An unnamed function that accepts a character and returns 1 (truthy) if present in its source code or 0 (falsey) if not.

Try it online! (Python 3) Or Try in Python 2 Or Try in Python 1.

TinyAPL beta 0.13.0, 10 bytes

∊∘"∊∘⍘"⍘⍘"

is the character contained in the string ∊∘"⍘?

Jelly, 4 bytes

e⁾e⁾

A monadic Link that accepts a single character and yields 1 (truthy) if it is one of the two used in the source code and 0 (falsey) otherwise.

Try it online!

How?

e⁾e⁾ - Link: character, C
 ⁾e⁾ - two-character list -> "e⁾"
e    - {C} exists in {that}?

If a full program were allowed, then 0 bytes - ignoring stdin TIO.

Retina 0.8.2, 1 byte

1

Try it online! Link includes... test cases? But there's not much to test really. The program counts the number of 1s in the input, so if the input is 1, the program outputs 1 accordingly, otherwise the input character is not in the program's code, and therefore the output is 0.

(Shamelessly stolen from my answer to Source Code Byte Frequency. As you can see, almost any single character would work.)

Uiua 0.17.0-dev.1, 6 bytes SBCS

∊$  $∊

Try on Uiua Pad!

A palindrome! Simply checks whether the character is a member of the string $∊.

Python: 31 bytes

d=lambda d:d in"\\ \":=abdilmn"