Just for curiosity.
Is it possible to create a regular expression that will not match any string, including an empty string?
Just for curiosity.
Is it possible to create a regular expression that will not match any string, including an empty string?
Yes.
Here are a few examples.
.^
$.
(?!)
Naturally, there are an infinite number of such expressions.
.^
, ..^
, ...^
, etc. –
Ida This regex should never match anything (provided you do not use single-line or multi-line modifiers):
$x^
How about /^$x/.
When I try it with ruby, it seems to work.
© 2022 - 2024 — McMap. All rights reserved.
NULL
,undef
orNone
: sometimes you want to have compiled regex as starting value that never matches anything – Nilsnot a real question
? If may not matter for this user right now, but it WILL matter to other users who will read this question later. – Nils