BSW.Blog

Extract CSS Class Names From Multiple Files Using Regular Expression in Powershell.

PS C:\> cat *.css| %{[System.Text.RegularExpressions.Regex]::Matches($_,"[^\d:](\.[\w-]{1,})[\ \{:\r\n\[]")} |%{$_.Groups[1].value} |sort -Unique

Now Upgraded Version

PS C:\css> cat *.css| %{[System.Text.RegularExpressions.Regex]::Matches($_,"(\.[^\d ][\w-]{1,})[ \r\n\t,:\{]*")} |%{$_.Groups[1].value} |sort -Unique

and Again Upgraded Version

PS C:\css> cat *.css| %{[System.Text.RegularExpressions.Regex]::Matches($_,"(?:[^\w])\.(?<g>[^\d/ ][\w-]{1,})|^\.(?<g>[^\d/ ][\w-]{1,})")} |%{$_.Groups[1].value} |sort -Unique

Babak
#CSS #Powershell #Multiple #File #Class #CSS3 #Regex #Regular #Regexp #Regular Expression
5/15/2014 5:29:49 PM
Write Comment