我试图在{}
中获取所有不属于变量的属性到目前为止,我的RegExp是这样的:
\s*[a-zA-Z-]*:[^@].*?;
示例文字
@footerBackground: @Color1;
@footerText: @Color3;
footer { background:@footerBackground url(images/bg.transp.fabric-45degreee_fabric.png) repeat; box-shadow:0 -1px 3px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(0, 0, 0, 0.1); bottom:0; color:@footerText; position:absolute; width:100%; }
footer a { color:@footerLink !important; }
footer a:hover { color:darken(@footerLink, 15%) !important; text-decoration:none; }
#footer-widgets { border-bottom:1px darken(@footerBackground,10%) dotted; padding:20px 0; }
有谁能告诉我我该怎么做这个表达?
示例
discart if have @ - color:darken(@tuningfooterLink, 15%) !important;
get - text-decoration:none;
答案 0 :(得分:1)
编辑:
试试这个:
$a = Get-Content .\your.css
$b = $a | % { $_ -replace "({\s*[a-zA-Z-]*:[^@].*\))(.*;)(\s*}$)", '$1$3' }
然后你可以做
Set-Content -Path .\yourchanged.css -Value $b.
一个班轮可以是:
( Get-Content .\your.css ) | % { $_ -replace "({\s*[a-zA-Z-]*:[^@].*\))(.*;)(\s*}$)", '$1$3' } | Set-Content -Path .\yourchanged.css
答案 1 :(得分:1)
我不知道powershell,但生病了正在使用正则表达式:
([a-zA-Z_-]+:[^}{@]*?;)
应捕获任何不包含@
的css类属性我认为
( #group1
[a-zA-Z_-] #Character class matching a-z, A-Z, _ and -
+ #match character class atleast once (applies to [a-zA-Z_-])
: #match a :
[^}{@] #Character class matchting all characters except {, }. and @
+ #match character class atleast once (applies to [^}{@])
? #dont be a greedy matcher (applies to +)
; #match a ; the closing char for any valid CSS rule
) #close group1