# Quinean Regex Tester

This challenge is pretty simple. As input, you take in a regular expression.

Then, you output a truthy/falsey of whether or not your source code matches the regular expression. It's that simple! Just two more things:

• No quine builtins; you may, however, access the code's source code by file IO, etc.
• This is , so shortest code in bytes wins!

## Example

If your source code was say, abc, an input of a\wc would return true and an input of a\dc would return false.

• Example please? – Mama Fun Roll Jan 12 '16 at 2:29
• @CᴏɴᴏʀO'Bʀɪᴇɴ no, that's fine. – Maltysen Jan 12 '16 at 2:31
• 1. I don't think just a BRE with simple character classes is specific enough. What BRE features have to be supported? 2. \d is not special in BRE; it matches the character d. 3. Choosing a specific regex flavor restricts your challenge to languages that support it, and few languages support BRE. Is that intentional? – Dennis Jan 12 '16 at 2:33
• I'd recommend leaving it up to the answerer. If language x uses regex flavor y by default, let it use that flavor in this challenge. – Dennis Jan 12 '16 at 2:36
• @Maltysen Why don't you add a substring example to the question body? – feersum Jan 12 '16 at 3:10

# Z shell, 12 bytes

grep "$@"<$0


Zsh conditionals understand only exit codes, and the scripts exits with 0 or 1 accordingly.

In addition, this prints a non-empty string (the source code) for a match and an empty one for a mismatch, which could be as truthy/falsy values in combination with test/[.

The program reads its own file, but according to this comment by the OP, this is allowed.

• Aaand Dennis won. ¯\_(ツ)_/¯ – Conor O'Brien Jan 12 '16 at 2:43
• This doesn't work. It breaks on patterns with spaces in them. – feersum Jan 12 '16 at 2:51
• @feersum Whoops! Thanks for pointing that out. I have edited my answer. – Dennis Jan 12 '16 at 2:53
• Now it breaks if it is written to a file with spaces in the name. Or a file called -v. Or... – Ben Millwood Jan 12 '16 at 15:08
• @BenMillwood I'd normally say don't save it with such a file name, but switching to zsh makes it bullet proof without incrementing the byte count. – Dennis Jan 12 '16 at 15:24

$_=<0>=~$_ reads one line from the source file, does a regex match against the contents of $_ (which were read by the -p flag), and assigns the result to $_. -p prints $_ automatically at the end. # Jolf, 18 15 bytes Supports the JS flavour of RegEx, I hope that's okay. Try it here!.  h$code.value#i


Commented:

  \$code.value#      the document's element "code" (the program container)
_h            i     and output if it has (matches) the input string (i.e. regex)

• In which browser does this work? Both Chrome and Firefox complain that x.step is not a function. – Dennis Jan 12 '16 at 14:27
• @Dennis Huh. I must have broken the interpreter last night. What else is wrong? I currently am unable to debug, am at school. – Conor O'Brien Jan 12 '16 at 15:02
• Good. Now add a shortcut to the document's element "code" so we can make it shorter. – user48538 Jan 12 '16 at 15:26
• @CᴏɴᴏʀO'Bʀɪᴇɴ It also gives a reference error for math. – Dennis Jan 12 '16 at 15:26
• @Dennis Ah, that's why. I forgot to update the HTML, I added math.js. I will revise when I arrive home, if that's not too late. (In about 4 ish hours) – Conor O'Brien Jan 12 '16 at 15:51

# 𝔼𝕊𝕄𝕚𝕟, 14 chars / 26 bytes (non-competitive)

⟮‼(ⒸⅩ222+ᶈ0)đï


Try it here (Firefox only).

Using a version with bug fixes written after the challenge.

# Explanation

⟮‼(ⒸⅩ222+ᶈ0)đï // implicit: ï=input
⟮               // copy block: copy following code for later use
(ⒸⅩ222+ᶈ0)   // take convert 10222 to char, add stuff inside copy block
‼           đï // check if input matches resulting string
// implicit output


NOTE: Copy blocks are NOT quine operators. They are meant to be more versatile alternatives to variable declarations.

• I think you can save a byte by changing Ⅹ to 10. – lirtosiast Jan 12 '16 at 5:59