Regex (ECMAScript), 29 bytes
^(?!(xx+|(x(x))+)(1円3円)+$)xxx
Inspired by Grimy in chat
The regex asserts that the input is greater than 3, and that it is neither of the form: (xx+)1円+ or ((xx)+)(1円x)+.
The first matches composite numbers greater than 3.
The second matches a number that is 1 less than a multiple of some odd number greater than 2.
The first will not match prime numbers, or 0 or 1.
The second will not match numbers of the form \2ドル^n-1\$, or numbers that are 1 less than an odd prime.
Since 2 is the only prime that is 1 less than an odd prime, the negative lookahead, together with the assertion that the input is greater than 3, will match only mersenne primes.
Regex (ECMAScript), 29 bytes
^(?!(xx+|(x(x))+)(1円3円)+$)xxx
Inspired by Grimy in chat
The regex asserts that the input is greater than 3, and that it is neither of the form: (xx+)1円+ or ((xx)+)(1円x)+.
The first matches composite numbers greater than 3.
The second matches a number that is 1 less than a multiple of some odd number greater than 2.
The first will not match prime numbers, or 0 or 1.
The second will not match numbers of the form \2ドル^n-1\$, or numbers that are 1 less than an odd prime.
Since 2 is the only prime that is 1 less than an odd prime, the negative lookahead, together with the assertion that the input is greater than 3, will match only mersenne primes.
Regex (ECMAScript), 29 bytes
^(?!(xx+|(x(x))+)(1円3円)+$)xxx
Inspired by Grimy in chat
The regex asserts that the input is greater than 3, and that it is neither of the form: (xx+)1円+ or ((xx)+)(1円x)+.
The first matches composite numbers.
The second matches a number that is 1 less than a multiple of some odd number greater than 2.
The first will not match prime numbers, or 0 or 1.
The second will not match numbers of the form \2ドル^n-1\$, or numbers that are 1 less than an odd prime.
Since 2 is the only prime that is 1 less than an odd prime, the negative lookahead, together with the assertion that the input is greater than 3, will match only mersenne primes.
Regex (ECMAScript), 29 bytes
^(?!(xx+|(x(x))+)(1円3円)+$)xxx
Inspired by Grimy in chat
The regex asserts that the input is greater than 3, and that it is neither of the form: (xx+)1円+ or ((xx)+)(1円x)+.
The first matches composite numbers greater than 3.
The second matches a number that is 1 less than a multiple of some odd number greater than 2.
The first will not match prime numbers, or 0 or 1.
The second will not match numbers of the form \2ドル^n-1\$, or numbers that are 1 less than an odd prime.
Since 2 is the only prime that is 1 less than an odd prime, the negative lookahead, together with the assertion that the input is greater than 3, will match only mersenne primes.