0

{}内の変数が少なくないすべての属性をCSSで取得しようとしています

これまでのところ、私の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;
4

2 に答える 2

1

編集:

これを試して:

$a = Get-Content .\your.css
$b = $a | % { $_ -replace "({\s*[a-zA-Z-]*:[^@].*\))(.*;)(\s*}$)", '$1$3' }

それからあなたはすることができます

Set-Content -Path .\yourchanged.css -Value $b.

1 つのライナーは次のようになります。

( Get-Content .\your.css ) |  % { $_ -replace "({\s*[a-zA-Z-]*:[^@].*\))(.*;)(\s*}$)", '$1$3' } | Set-Content -Path .\yourchanged.css 
于 2012-05-09T11:50:49.333 に答える
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
于 2012-05-09T20:11:49.310 に答える