试试这个:
(?<=\}\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 «\}»
没有空白样式,图案不匹配!