是否有一个普通防爆pression永远不会匹配任何字符串? [英] Is there a Regular Expression that will never match any string?

查看:155
本文介绍了是否有一个普通防爆pression永远不会匹配任何字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个两部分的问题排序:

Sort of a two part question:

  1. 有没有什么理论经常EX pression不会匹配任何字符串(使用一般的语法,而不被现代常规EX pression的匹配提供的任何花哨的东西)?
  2. 有没有使用C#的正则表达式的语法来创建一个正则表达式不会匹配任何字符串一个简单的方法(这时候,所有的花哨的东西的的含税)
  1. 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)?
  2. 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).

这篇关于是否有一个普通防爆pression永远不会匹配任何字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆