how can skuname following text using powershell?
input: [{\"sku\":\"sku7120234\" parsed out should be: sku7120234
also, given timestamp of \"timestamp\":1447964164371}. can 1 advise on how integer value in date format.
if have specific file type or structure should post , desired output mentioned in comments.
simply parsing asked:
$str = '[{\"sku\":\"sku7120234\"'
option 1 - split string:
($str -split '\\')[3] -replace '"'
option 2 - regex match:
[regex]::match($str,'sku\d+').groups[0].value
results:
sku7120234
to millisecond timestamp datetime can this:
$ts = '\"timestamp\":1447964164371}' $epoch = [regex]::match($ts,'\d+').groups[0].value [datetime] $origin = '1970-01-01 00:00:00.000' [datetime] $result = $origin.addmilliseconds($epoch)
result:
#datetime type object result $result thursday, november 19, 2015 8:16:04 pm #or formatted string $result.tostring() 11/19/2015 8:16:04 pm
Comments
Post a Comment