Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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 Regex para adicionar um ní;层次结构的层次结构和层次结构_Css_Regex_Replace - Fatal编程技术网

Css Regex para adicionar um ní;层次结构的层次结构和层次结构

Css Regex para adicionar um ní;层次结构的层次结构和层次结构,css,regex,replace,Css,Regex,Replace,我想用一个正则表达式在sublime的“Find&Replace”中添加一个层次结构(例如,一个名为“myClass”的类)到所有css规则中 现行代码 div { width: 100%; border: 5px solid #F00; } .red-button { background: #F00; } div .red-button { color: #000; } 我需要什么 .myClass div { width: 100%; border

我想用一个正则表达式在sublime的“Find&Replace”中添加一个层次结构(例如,一个名为“myClass”的类)到所有css规则中

现行代码

div {
   width: 100%;
   border: 5px solid #F00;
}

.red-button {
   background: #F00;
}

div .red-button {
   color: #000;
}
我需要什么

.myClass div {
   width: 100%;
   border: 5px solid #F00;
}

.myClass .red-button {
   background: #F00;
}

.myClass div .red-button {
   color: #000;
}
css文件太大,我认为正则表达式有助于描述 替换为:
.myClass$1

例子 现场演示

示例文本

div {
   width: 100%;
   border: 5px solid #F00;
}

.red-button {
   background: #F00;
}

div .red-button {
   color: #000;
}
.myClass div {
   width: 100%;
   border: 5px solid #F00;
}

.myClass .red-button {
   background: #F00;
}

.myClass div .red-button {
   color: #000;
}
更换后

div {
   width: 100%;
   border: 5px solid #F00;
}

.red-button {
   background: #F00;
}

div .red-button {
   color: #000;
}
.myClass div {
   width: 100%;
   border: 5px solid #F00;
}

.myClass .red-button {
   background: #F00;
}

.myClass div .red-button {
   color: #000;
}
解释
请你把标题也翻译一下好吗?谢谢,效果很好!