<p>Is is possible to construct a regular expression that rejects all input strings?</p>

[{'answer_id': 62438, 'author': 'UnkwnTech', 'author_id': 115, 'author_profile': 'https://Stackoverflow.com/users/115', 'pm_score': -1, 'selected': False, 'text': '<p>EDIT:\n    [^\\n\\r\\w\\s]</p>\n'}, {'answer_id': 62473, 'author': 'Jan Hančič', 'author_id': 185527, 'author_profile': 'https://Stackoverflow.com/users/185527', 'pm_score': 1, 'selected': False, 'text': '<p>Why would you even want that? Wouldn\'t a simple if statment do the trick? Something along the lines of:</p>\n\n<pre><code>if ( inputString != "" )\n  doSomething ()\n</code></pre>\n'}, {'answer_id': 62475, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 4, 'selected': True, 'text': "<p>Probably this:</p>\n\n<pre><code>[^\\w\\W]\n</code></pre>\n\n<p>\\w - word character (letter, digit, etc)<br>\n\\W - opposite of \\w</p>\n\n<p>[^\\w\\W] - should always fail, because any character should belong to one of the character classes - \\w or \\W</p>\n\n<p>Another snippets:</p>\n\n<pre><code>$.^\n</code></pre>\n\n<p>$ - assert position at the end of the string<br>\n^ - assert position at the start of the line<br>\n. - any char  </p>\n\n<pre><code>(?#it's just a comment inside of empty regex)\n</code></pre>\n\n<p>Empty lookahead/behind should work:</p>\n\n<pre><code>(?&lt;!)\n</code></pre>\n"}, {'answer_id': 62497, 'author': 'Erik', 'author_id': 6733, 'author_profile': 'https://Stackoverflow.com/users/6733', 'pm_score': 0, 'selected': False, 'text': '<p>[^\\x00-\\xFF]</p>\n'}, {'answer_id': 62508, 'author': 'Fernando Barrocal', 'author_id': 2274, 'author_profile': 'https://Stackoverflow.com/users/2274', 'pm_score': -1, 'selected': False, 'text': '<p>Well,</p>\n\n<p>I am not sure if I understood, since I always thought of regular expression of a way to match strings. I would say the best shot you have is not using regex.</p>\n\n<p>But, you can also use regexp that matches empty lines like <code>^$</code> or a regexp that do not match words/spaces like <code>[^\\w\\s]</code> ...</p>\n\n<p>Hope it helps!</p>\n'}, {'answer_id': 62561, 'author': 'Henrik N', 'author_id': 6962, 'author_profile': 'https://Stackoverflow.com/users/6962', 'pm_score': 2, 'selected': False, 'text': '<pre><code>(?=not)possible\n</code></pre>\n\n<p>?= is a positive lookahead. They\'re not supported in all regexp flavors, but in many.</p>\n\n<p>The expression will look for "not", then look for "possible" starting at the same position (since lookaheads don\'t move forward in the string).</p>\n'}, {'answer_id': 62758, 'author': 'asksol', 'author_id': 5577, 'author_profile': 'https://Stackoverflow.com/users/5577', 'pm_score': 1, 'selected': False, 'text': '<p>To me it sounds like you\'re attacking a problem the wrong way, what exactly\nare you trying to solve?</p>\n\n<p>You could do a regular expression that catches everything and negate the result.</p>\n\n<p>e.g in javascript:</p>\n\n<pre><code>if (! str.match( /./ ))\n</code></pre>\n\n<p>but then you could just do</p>\n\n<pre><code>if (!foo)\n</code></pre>\n\n<p>instead, as @[jan-hani] said.</p>\n\n<p>If you\'re looking to embed such a regex in another regex, you\nmight be looking for <em>$</em> or <em>^</em> instead, or use lookaheads like @[henrik-n] mentioned.</p>\n\n<p>But as I said, this looks like a "I think I need x, but what I really need is y" problem.</p>\n'}, {'answer_id': 62896, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>It depends on what you mean by "regular expression".  Do you mean regexps in a particular programming language or library?  In that case the answer is probably yes, and you can refer to any of the above replies.  </p>\n\n<p>If you mean the regular expressions as taught in computer science classes, then the answer is no.  Every regular expression matches some string.  It could be the empty string, but it always matches <em>something</em>.</p>\n\n<p>In any case, I suggest you edit the title of your question to narrow down what kinds of regular expressions you mean.</p>\n'}, {'answer_id': 63905, 'author': 'squadette', 'author_id': 7754, 'author_profile': 'https://Stackoverflow.com/users/7754', 'pm_score': 2, 'selected': False, 'text': '<p>One example of why such thing could possibly be needed is when you want to filter some input with regexes and you pass regex as an argument to a function.</p>\n\n<p>In spirit of functional programming, for algebraic completeness, you may want some trivial primary regexes like "everything is allowed" and "nothing is allowed".</p>\n'}, {'answer_id': 70015, 'author': 'David Arno', 'author_id': 7122, 'author_profile': 'https://Stackoverflow.com/users/7122', 'pm_score': 0, 'selected': False, 'text': '<p><code>[^]+</code> should do it.</p>\n\n<p>In answer to aku\'s comment attached to this, I tested it with an online regex tester (<a href="http://www.regextester.com/" rel="nofollow noreferrer">http://www.regextester.com/</a>), and so assume it works with JavaScript. I have to confess to not testing it in "real" code. ;)</p>\n'}, {'answer_id': 79286, 'author': 'Chris Conway', 'author_id': 1412, 'author_profile': 'https://Stackoverflow.com/users/1412', 'pm_score': 3, 'selected': False, 'text': '<p>The <em>best</em> standard  regexs (i.e., no lookahead or back-references) that reject all inputs are (after @aku above)</p>\n\n<pre><code>.^\n</code></pre>\n\n<p>and</p>\n\n<pre><code>$.\n</code></pre>\n\n<p>These are flat contradictions: "a string with a character before its beginning" and "a string with a character after its end."</p>\n\n<p>NOTE: It\'s possible that some regex implementations would reject these patterns as ill-formed (it\'s pretty easy to check that <code>^</code> comes at the beginning of a pattern and <code>$</code> at the end... with a regular expression), but the few I\'ve checked do accept them. These also won\'t work in implementations that allow <code>^</code> and <code>$</code> to match newlines.</p>\n'}]
['https://Stackoverflow.com/questions/62430', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4984/']