Skip to content

Instantly share code, notes, and snippets.

@tripflex
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save tripflex/ea4ca0aeda66946a9845 to your computer and use it in GitHub Desktop.

Select an option

Save tripflex/ea4ca0aeda66946a9845 to your computer and use it in GitHub Desktop.
Powershell RegEx to Hash Table Key->Value pairs
$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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment