(?<selector>[^\{\s]+\w+(\s\[^\{\s]+)?)\s?\{(?<style>[^\}]*)\}
以上几乎与所有情况相符。
audio:not([controls])
{
display:none
}
任何类似的东西(方括号)都不能正确匹配。
button,input[type="button"],input[type="reset"],input[type="submit"]
{
cursor:pointer;-webkit-appearance:button
}
input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button
{
-webkit-appearance:none
}
这些......
答案 0 :(得分:0)
试试这个:
(?<=\}\s*)(?<selector>[^\{\}]+?)(?:\s*\{(?<style>[^\{\}]+)\})
说明:
// (?<=\}\s*)(?<selector>[^\{\}]+?)(?:\s*\{(?<style>[^\{\}]+)\})
//
// Options: case insensitive; ^ and $ match at line breaks
//
// Assert that the regex below can be matched, with the match ending at this position (positive lookbehind) «(?<=\}\s*)»
// Match the character “}” literally «\}»
// Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) «\s*»
// Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
// Match the regular expression below and capture its match into backreference with name “selector” «(?<selector>[^\{\}]+?)»
// Match a single character NOT present in the list below «[^\{\}]+?»
// Between one and unlimited times, as few times as possible, expanding as needed (lazy) «+?»
// A { character «\{»
// A } character «\}»
// Match the regular expression below «(?:\s*\{(?<style>[^\{\}]+)\})»
// Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) «\s*»
// Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
// Match the character “{” literally «\{»
// Match the regular expression below and capture its match into backreference with name “style” «(?<style>[^\{\}]+)»
// Match a single character NOT present in the list below «[^\{\}]+»
// Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
// A { character «\{»
// A } character «\}»
// Match the character “}” literally «\}»
没有空白样式,模式不匹配!