Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
解析出css规则块_Css_Regex - Fatal编程技术网

解析出css规则块

解析出css规则块,css,regex,Css,Regex,男人们有这样的css片段 /** Correct default cursor behaviour across the site relies on body having cursor: default below. */ * { font-size: 12em; } div { cursor: inherit; } html, body, #main-view-target { height: 100%; width: 100%; margin: 0;

男人们有这样的css片段

/**
    Correct default cursor behaviour across the site
    relies on body having cursor: default below.
*/
* { font-size: 12em; }
div {
  cursor: inherit;
}
html,
body,
#main-view-target {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  cursor: default;
  background: url("{ROOT}../img/bg.png")no-repeat;
}
需要用regexp解析所有属性块,但是{ROOT | VERSION}元指令不允许我这样做。
如何省略该指令?

({(?>[^}]+|)(?:)您使用的是哪种工具。这是我们需要帮助的最低信息。欢迎使用。此处的问题应显示研究工作或尝试。请回答.X/Y问题;您不需要(Y)使用regexp解析所有属性块;相反,您需要(X)找到某个问题的解决方案(哪一个是什么?),您认为是使用regexp解析属性块的解决方案。通常,您不应该像解析HTML那样尝试使用regexp解析CSS。浏览器及其API知道如何比您更高效、更可靠地解析内容。在这种情况下,浏览器已将规则解析为其样式表对象,您可以使用eg
document.styleSheets[0].cssRules[1]检查并修改的值.style.backgroundImage
。我使用的是原生C#Regex。你的意思是吗?对于测试Regex,我使用的是regex101.com或Regex Coachto torazaburo:我坚持使用该解决方案,因为实现了一个我无法重写的程序。否则我会选择不同的方式。我已经编辑掉了你关于否决票的投诉。不要在你的报告中添加噪音帖子,使用评论进行与帖子相关的讨论。阅读更多:这可能更一般,因为我又添加了一个占位符{SETTING:[anyName]},并且这个模式不再有效。尝试使用它,但没有成功。
({(?>[^}]+|(?:(?<={ROOT)|(?<={VERSION))})*})