Is there a regular expression that will never match any string?
Ask the question in two parts:
- Is there any theoretical regex that will never match any string (using a general syntax without any of the fancy stuff provided by modern regex)?
- Is there an easy way to use the C # Regex syntax to create a regex that will never match any string (all the fancy stuff included this time)?
NOTE. I am not referencing empty string matching (that would be simple, simple ""
).
+2
source to share
3 answers
Without multiline mode, the end usually doesn't appear before the start:
$.^
Or simpler, again without multi-line mode:
$.
With search engines, you can do all sorts of conflicting things:
(?=a)(?=b)
This forces the hero to be two different things at once, which, of course, is impossible.
+7
source to share