Powershell RegEx to Hash Table Key->Value pairs

conftohashtable.ps1


$configData = "system_date='2014/11/13'
system_time='14:40:15'
system_ntp='192.168.150.48'
system_daylight_enable='1'
system_updateinterval='3600'
"

$regex = [regex]("(w+)(?=='(.*)')")

$camConfs = @{}

$regex.matches( $configData ) | ForEach-Object {

	$camConfs["$_"] = $_.groups[2].value
}

echo $camConfs
No comments yet.

Leave a Reply