是否有一个普通防爆pression永远不会匹配任何字符串?永远不会、字符串、有一个、普通

2023-09-04 00:58:07 作者:匿名

一个两部分的问题排序:

Sort of a two part question:

有没有什么理论经常EX pression不会匹配任何字符串(使用一般的语法,而不被现代常规EX pression的匹配提供的任何花哨的东西)? 有没有使用C#的正则表达式的语法来创建一个正则表达式不会匹配任何字符串一个简单的方法(这时候,所有的花哨的东西的是的含税)? Is there any theoretical regular expression that will never match any string (using general syntax without any fancy stuff provided by modern regular expression matchers)? Is there a simple way to use C#'s Regex syntax to create a regex that will never match any string (this time, all the fancy stuff is included)?

注:我的不可以指匹配空字符串(这将是很容易,只要

NOTE: I am not referring to matching the empty string (that would be easy, just "").

推荐答案

正如你可以搭配 [\ S \ S] ,你可以匹配任何字符的任何字符与 [^ \ S \ S] (或 [^ \ W \ W] 等)。

Just as you can match any characters with [\s\S], you can match no characters with [^\s\S] (or [^\w\W], etc).