unknown
2007-11-28 02:41:02 UTC
Here is my powershell code:
$tabFile = [string]::Join([environment]::NewLine, (Get-Content
"C:\data\!!sandbox\dhcp\dhcp3tab"))
##$tabFile = @"
##[Subnet : "172.29.11.0(VLAN19)"]
## Subnet Address = 172.29.11.0
## Subnet Mask = 255.255.255.0
## Lease Time = 259200
## Config Options = 00 00 00 00 03 04 AC 1D 0B 01
## Zone Reference = bdokendalls_com_au.BDOK
## Domain Name = bdokendalls.com.au
## Subnet Type = 1
##
##[Subnet Address Range : "Subnet Server.VLAN19.BDOK"]
## Start Address = 172.29.11.0
## End Address = 172.29.11.0
## DHCP Server Reference = "DHCP_NWC-BNE-B.BRIS.BDOK"
## Range Type = 99
##
##[Subnet Address Range : "LAN.VLAN19.BDOK"]
## Start Address = 172.29.11.50
## End Address = 172.29.11.250
## DHCP Server Reference = "DHCP_NWC-BNE-B.BRIS.BDOK"
## Range Type = 3
## DNS Update Option = 2
##"@
$RegexOptions = [System.Text.RegularExpressions.RegexOptions]
$options = ($RegexOptions::Multiline -bor $RegexOptions::IgnoreCase)
$regex = @"
^\[(?<name>[^\r\n]+)\ :\ "(?<desc>[^"\r\n]*)"\](?:\n\t(?<lines>.+?))*$
"@
$reg = new-object System.Text.RegularExpressions.Regex($regex, $options)
$matches = $reg.Matches($tabFile)
$matches.Count
$matches | Foreach-Object {
$_.Groups["name"].Value
$_.Groups["desc"].Value
$_.Groups["lines"].Captures | foreach-Object {
$_.Value
}
}
I've tested this regular expression in a program called the regulator and it
works perfectly. Unfortunately when running it in powershell it does not
match anything. If I remove the $ it does match some of what i want but not
all. Is this a bug?
$tabFile = [string]::Join([environment]::NewLine, (Get-Content
"C:\data\!!sandbox\dhcp\dhcp3tab"))
##$tabFile = @"
##[Subnet : "172.29.11.0(VLAN19)"]
## Subnet Address = 172.29.11.0
## Subnet Mask = 255.255.255.0
## Lease Time = 259200
## Config Options = 00 00 00 00 03 04 AC 1D 0B 01
## Zone Reference = bdokendalls_com_au.BDOK
## Domain Name = bdokendalls.com.au
## Subnet Type = 1
##
##[Subnet Address Range : "Subnet Server.VLAN19.BDOK"]
## Start Address = 172.29.11.0
## End Address = 172.29.11.0
## DHCP Server Reference = "DHCP_NWC-BNE-B.BRIS.BDOK"
## Range Type = 99
##
##[Subnet Address Range : "LAN.VLAN19.BDOK"]
## Start Address = 172.29.11.50
## End Address = 172.29.11.250
## DHCP Server Reference = "DHCP_NWC-BNE-B.BRIS.BDOK"
## Range Type = 3
## DNS Update Option = 2
##"@
$RegexOptions = [System.Text.RegularExpressions.RegexOptions]
$options = ($RegexOptions::Multiline -bor $RegexOptions::IgnoreCase)
$regex = @"
^\[(?<name>[^\r\n]+)\ :\ "(?<desc>[^"\r\n]*)"\](?:\n\t(?<lines>.+?))*$
"@
$reg = new-object System.Text.RegularExpressions.Regex($regex, $options)
$matches = $reg.Matches($tabFile)
$matches.Count
$matches | Foreach-Object {
$_.Groups["name"].Value
$_.Groups["desc"].Value
$_.Groups["lines"].Captures | foreach-Object {
$_.Value
}
}
I've tested this regular expression in a program called the regulator and it
works perfectly. Unfortunately when running it in powershell it does not
match anything. If I remove the $ it does match some of what i want but not
all. Is this a bug?
--
**********************
Jacob
**********************
Jacob