[Question]
  [
Your mission is to write the shortest valid regular expression that no string can match, empty string included.
Submissions must have this form ("literal notation"):
```
/pattern/optional-flags
```
Shortest regexp wins. The regexp size is counted in characters. (including slashes and flags)
Please explain how your regexp works (if it's not trivial)
Thanks, and have fun!
  
[Answer]
# **6 chars**
Following on the answers of primo and Peter Taylor, and a hint from `man perlre`:
`/(?!)/`
This perl-compatible regex matches an empty string which is not followed by another empty string.
[Answer]
## 8 chars
```
/(?=a)b/
```
We require a string containing a character which is both `a` and `b`, which is obviously impossible.
[Answer]
## 5 chars
Unlike everybody who abuses `$` and `^`... this actually works in Perl:
```
/V\A/
```
`\A` matches the beginning of the string.
[Answer]
# 6 chars
```
/x\by/
```
Based on [Sven Hohenstein's answer](https://codegolf.stackexchange.com/a/18402/2972).
[Answer]
### 8 characters
```
/\w\b\w/
```
A word boundary (`\b`) surrounded by 'word' characters (`\w` - one of `[_a-zA-Z0-9]`). It is unmatchable since one of the characters preceding or following a word boundary must be a non-'word' character.
By the way: this is similar to the unmatchable expression
```
/\W\b\W/
```
where `\W` means non-'word' character.
[Answer]
## 4 chars
```
/$a/
```
searches a "a" after the end of the string.
or
```
/a^/
```
searches a before the beginning of the string.
[Answer]
**5 characters**
`/$.^/`
`/$^/` will match an empty string, whereas requiring a character in between will not.
[Answer]
# 9 chars
I'm not sure but `/[^\S\s]/` should be unmatchable since it means not any character, but at least one of them.
[Answer]
# 4 characters
(ECMAScript flavour only)
```
/[]/
```
In other flavours this is not a valid character class (the `]` would be considered a character *in* the class, so the expression isn't valid, because the class is never closed), but the ECMAScript standard accepts empty character classes. Since it is a class it *has* to match a character (so empty strings don't match), but since not a single character is included no actual character will match either.
[Answer]
# 6 characters
```
/\b\B/
```
This matches a word boundary (`\b`) that isn't a word boundary (`\B`), which is obviously impossible.
[Answer]
### 6 chars
```
/b++b/
```
Possessive quantifier looks for as many b's as possible, then 1 more. 6 chars but points for symmetry?
[Answer]
## 6 characters
```
/(\1)/
```
Not a winner, but I thought it was fun. grep and Python both barf on this one, but Perl seems okay with it.
Seems to be *very* implementation-dependent (which is hardly surprising, given its weirdness). [Bob](https://codegolf.stackexchange.com/users/4163/bob) reports below that it matches *anything* in JavaScript's regex engine.
[Answer]
Maybe a bit of cheating, but…
```
\0
```
… is unmatchable in [POSIX regex](https://www.mirbsd.org/man7/re_format) in virtually all, if not all, implementations. BASIC RE and EXTENDED RE, even.
And POSIX RE does not need those pesky slashes and flags PCRE has.
[Answer]
# 4 char:
```
/.^/
```
Works with GNU grep 2.5.1 and egrep.
[Answer]
# Perl 6 (5 characters)
```
/<!>/
```
Sorta rule abuse (because Perl 6 regexes are different, and incompatible with stardard regexes by design), but I don't care. `<!>` rule informs Perl 6 that the regex doesn't match.
[Answer]
## 6 bytes
```
/(*F)/
```
An abbreviation for `(*FAIL)`, supported by perl-compatable regex engines. Thanks to [@HamZa](https://codegolf.stackexchange.com/questions/18393/#comment35888_18431) for pointing this out.
## 9 bytes
```
/(*FAIL)/
```
Should work with any regex engine that supports verbs at all. I'm not convinced this really needs to be golfed any further.
[Answer]
# **5 chars**
```
/^.^/
```
Matches string that begin with any single character before string begin.
[Answer]
### 4 chars with slashes 2 without
In the TXR language's regex engine, an empty character class `[]` matches no character, and therefore no string. It behaves this way because the character class requires a character match, and when it is empty it specifies that no character can satisfy it.
Another way is to invert the "set of all strings including empty" regex `/.*/` using the complement operator: `/~.*/`. The complement of that set contains no strings at all, and so cannot match anything.
This is all documented in the man page:
```
   nomatch
          The  nomatch  regular  expression  represents  the empty set: it
          matches no strings at all, not even the empty string.  There  is
          no  dedicated  syntax  to  directly express nomatch in the regex
          language.  However, the empty character class []  is  equivalent
          to nomatch, and may be considered to be a notation for it. Other
          representations of nomatch are possible: for instance, the regex
          ~.* which is the complement of the regex that denotes the set of
          all possible strings, and thus denotes the empty set. A  nomatch
          has  uses;  for instance, it can be used to temporarily "comment
          out" regular expressions. The regex ([]abc|xyz) is equivalent to
          (xyz), since the []abc branch cannot match anything. Using [] to
          "block" a subexpression allows you to leave it  in  place,  then
          enable it later by removing the "block".
```
The slashes are not part of the regex syntax per se; they are just punctuation which delimits regexes in the S-expression notation. Witness:
```
# match line of input with x variable, and then parse that as a regex
#
$ txr -c '@x
@(do (print (regex-parse x)) (put-char #\newline))' -
ab.*c                               <- input from tty: no slashes.
(compound #\a #\b (0+ wild) #\c)    <- output: AST of regex
```
[Answer]
# 4 chars
```
/$./
```
Needs any character after the string ends
[Answer]
**6 chars**
**(or 4, depending on how you look at it)**
```
/{,0}/
```
[Answer]
This is a 5 char regex.
```
/[]+/
```
It matches an empty group 1 or more times.
EDIT:
Removed my answer for other flavours:
```
/.{-1}/
```
Anything that is not a number inside {} will match the text.
This one will match ".{-1}"
[Answer]
### 5 characters
Hope this doesnt sound stupid: `/[]+/`
[Answer]
```
/$^/
```
A thing that ends before it has begun...
]