21
0
Your task here is to write two regular expressions, each of which matches the other one but does not match itself.
Both regular expressions should have this form:
/pattern/optional-flags
This is also the form in which they should be matched.
The shortest solution wins. The solution length is counted as the sum of characters in both regular expressions including slashes and flags.
Use a regex syntax standard of your choice, or specify a programming language, when it makes a difference.
Have fun!
Does the regex also have to match the slashes and flags of the other regex? – ProgramFOX – 2014-03-02T15:30:33.577
@ProgramFOX yes, I added a line to make it clear. – GOTO 0 – 2014-03-02T15:35:17.113
Can you define match? i.e. does the regex
/a/
matchabc
? – The Guy with The Hat – 2014-03-02T20:05:55.1002@TheGuywithTheHat well, I think so, unless you choose a language that imposes certain restrictions, like the need to match the whole string. Does this address your concern? – GOTO 0 – 2014-03-02T20:21:37.743
1To be clear: I assume that the use of different delimiters (as permitted by e.g. PHP PCRE) is not permitted? (I.e. no submitting
/^%/
and%^/%
) – Peter Taylor – 2014-03-03T09:27:14.117@PeterTaylor you're right. There are ways to create a regular expression that don't even need you to use a delimiter. The syntax requirements are there to keep the rules simple and clear. They're not just arbitrary limitations. – GOTO 0 – 2014-03-03T10:02:06.213
This is very quine-like, should it be tagged quine? – Cruncher – 2014-03-03T18:56:12.603
@Cruncher, the only output produced is a couple of Booleans. It doesn't fit the current definition of the [tag:quine] tag, and that definition fits pretty well with what I understand to be the standard meaning of the term. – Peter Taylor – 2014-03-03T19:08:03.087
@PeterTaylor That's generally why we call them variants. If I had a program that returned true when the input was its own source, and false otherwise, that would be very quine-like without ever fitting the output requirements of a true quine. In fact the question exists http://codegolf.stackexchange.com/questions/11370/write-the-shortest-self-identifying-program-a-quine-variant and is tagged quine.
– Cruncher – 2014-03-03T19:11:49.933