7
\$\begingroup\$

You must make a regex that matches everything except itself. For example, PPCG must not match PPCG, but must match everything else, like something, PPC, and PPCG!.

Surrounding slashes are not considered part of the regex in flavors where they are usually part of the syntax. The same is true of all delimiters.

The regex needs to match the entire string, not just a substring.

You may choose your flavor, but you can't use a flavor newer than this challenge. Please pick a flavor that is easily tested.

Shortest regex in bytes wins.

(Sandbox (deleted))

\$\endgroup\$
9
  • 2
    \$\begingroup\$ Related \$\endgroup\$
    – user58826
    Jun 9, 2017 at 1:24
  • \$\begingroup\$ Also, jimmy's solution to the previous challenge can be inverted quite trivially to make a valid answer for this one. \$\endgroup\$ Jun 9, 2017 at 10:54
  • 1
    \$\begingroup\$ I love how you pointed out a related question on your own question. \$\endgroup\$ Jun 9, 2017 at 15:04
  • 2
    \$\begingroup\$ @carusocomputing Why wouldn't they? The point of related links is to make the challenges show up in each others' sidebars. \$\endgroup\$ Jun 9, 2017 at 15:05
  • \$\begingroup\$ @MartinEnder would assume one would put it in the post itself, not as a comment is all I was saying ;). \$\endgroup\$ Jun 9, 2017 at 16:02

1 Answer 1

6
\$\begingroup\$

PCRE flavour, 45 bytes

^(?!\^()(?R){2}\z)|\1\Q(?!\^()(?R){2}\z)|\1\Q

Try it at regex101.

This is a simple modification of jimmy23013's brilliant solution to the opposite challenge. We just need to make two changes:

  • In this challenges, the delimiters shouldn't be matched so we drop them from the regex as well. However, that could lead to infinite recursion, because then no characters would be matched before the (?R) call. To fix this, we match the ^ explicitly with \^ to have one character before we enter the recursion.
  • We need to negate the result which is as simple as wrapping everything after the ^ in a negative lookahead to ensure that the input isn't equal to the string.

For the details of this quining approach, see jimmy's amazing answer.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ Even though it's a modification of that other answer I wouldn't have had a clue about how to do it so +1 \$\endgroup\$ Jun 9, 2017 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.