I am trying to solve this problem using PowerShell and Regex. I have a string variable like the following:
$input = @"
Server Time: 4/13/2016 12:29 PM
Username: RBullwinkle
Lorem ipsum dolor Important Data: rosebud sit amet
"@;
I would like to extract data such that I receive the following result:
$serverTime = "4/13/2016 12:29 PM"
$userName = "RBullwinkle"
$important = "rosebud"
This would be a straightforward regex except for the following complications:
- I would like the extraction to be robust to any changes in the order of the data.
- I would like to process the input string in a single pass.
ConvertFrom-StringData. You can do that with very little regex. Just need to change the : to = and it should work. I have a few posts about this approach.