Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access the values of the hash table
#1
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:
Code:
Copy      Help
$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']


Messages In This Thread
Access the values of the hash table - by Davider - 12-03-2022, 01:42 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)