Hi,
I want to store multiple lines of text in the key of the hash table, after which I can access the value through the key
Below is an example of Powershell code
In QM, how to implement similar functions? Or, how to create a function with similar functionality?
Thanks in advance for any advice and help
david
Powershell Code:
I want to store multiple lines of text in the key of the hash table, after which I can access the value through the key
Below is an example of Powershell code
In QM, how to implement similar functions? Or, how to create a function with similar functionality?
Thanks in advance for any advice and help
david
Powershell Code:
$s = @'
mes1 :sub.Sub1
mes2 :sub.Sub2
#sub Sub1 m
_s="hello 1"
mes _s
#sub Sub2 m
_s="hello 2"
mes _s
'@
$hash = @{ }
foreach ($m in [regex]::Matches($s, '(?m)^#sub Sub(\d+) m(?:(?!^#sub Sub\d+ m)[\s\S])+'))
{
$key = $m.Groups[1].Value
$value = $m.Groups[0].Value.Trim()
if (!$hash.Contains($key))
{
$hash.Add($key, $value)
}
}
$hash['1']