PowerShell.hrc for Colorer, version 1.3.4


PowerShell.hrc for Colorer, version 1.3.4

 

EDIT: This version is obsolete. The latest PowerShell.hrc is included into the featured version of PowerShellFar plug-in for Far Manager: http://code.google.com/p/farnet/

 

What’s new: REGEX and SQL schemes are supported in PowerShell literal strings.

Flexibility and power of COLORER is amazing – it not only supports tons of file formats, but also allows combining schemes together (e.g. HTML scheme supports embedded JScript, VBScript and etc. reusing their schemes). As for the PowerShell, in new version of PowerShell.hrc I tried to use REGEX and SQL schemes in literal strings.

  • REGEX scheme is used in string operand of -match, -notmatch, -replace and etc.
  • Here strings are processed with REGEX or SQL schemes starting with lines #REGEX or --SQL respectively. Note that regex normally should be created with option IgnorePatternWhitespace or it should use inline instruction (?x).

Examples of highlighting in PowerShell strings

### Regex in operands

"ab11* 'foo'" -notmatch '^ab[0-2](d+)*s+''(w+)\'''
'ab11* "foo"' -match "^ab[0-2]$(2 - 1)*s+$($null)$null`"foo\`""
'2007-9-23' -replace 'b(d{2,4})-([01]?d)-([012]?d)b', '$3/$2/$1'

### Regex in here strings

$re = @'
#REGEX Id and Name
#(?<Id>d+)           # #number
s+                    # spaces
(?<Name>[_a-zA-Z]w*)  # name
'@

# how to use such a pattern:
New-Object Regex $re, 'IgnorePatternWhitespace'

### SQL in here strings

@'
--SQL single quoted
SELECT Data1, COUNT(1)
FROM Table1
WHERE Data1 = '$literal'
GROUP BY Data1
'@

@"
--SQL double quoted
SELECT Data1, COUNT(1)
FROM $Table
WHERE $x = '$variable'
GROUP BY Data1
"@


Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: