13
1
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 code-golf, 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 – 2016-01-12T02:29:00.800
Would accessing the file/textarea in which the code is contained in count as a builtin? – Conor O'Brien – 2016-01-12T02:30:02.787
1@CᴏɴᴏʀO'Bʀɪᴇɴ no, that's fine. – Maltysen – 2016-01-12T02:31:07.040
For your example, would regex
a
return true or false? – Mama Fun Roll – 2016-01-12T02:33:02.2602>
\d
is not special in BRE; it matches the characterd
. 3. Choosing a specific regex flavor restricts your challenge to languages that support it, and few languages support BRE. Is that intentional?@Dennis I'm not sure how regex's and flavours and stuff work, BRE was a name someone recommended in chat, and I kind of went with it. What do you recommend so answers don't have to worry about flavor specific features. – Maltysen – 2016-01-12T02:34:46.553
2I'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 – 2016-01-12T02:36:12.987
@Maltysen "Use whatever RegEx is native to the language, or, BRE" – Conor O'Brien – 2016-01-12T02:36:13.890
@Dennis makes sense. – Maltysen – 2016-01-12T02:36:54.157
Must the regex match the entire source code, or can it match a substring of the source code? – feersum – 2016-01-12T02:45:41.573
@feersum substring (unless, of course, it uses
^$
) – Maltysen – 2016-01-12T02:46:41.0036@Maltysen Why don't you add a substring example to the question body? – feersum – 2016-01-12T03:10:24.157