在字典中分割类似于ini文件的文本

问题描述 投票:0回答:1

我想在字典中拆分文本变量的内容。内容是格式为key = value的行序列。

Owner = [email protected] \r\n Validator = [email protected] \r\n Approver = [email protected] \r\n

谢谢您的帮助。萨尔瓦多

g1ant
1个回答
0
投票

您可以尝试:

♥text = ⊂"Owner =  [email protected]\r\nOwner2 = [email protected]"⊃
text.find text ♥text regex ‴(?<keys>.*)=(?<values>.*)‴
for ♥i from 1 to ♥keys⟦count⟧
      if ⊂♥i == 1⊃
          ♥dict = ⟦dictionary⟧♥keys⟦♥i⟧❚♥values⟦♥i⟧
      else
          ♥dict⟦♥keys⟦♥i⟧⟧ = ♥values⟦♥i⟧
      end if
end for
dialog ♥dict⟦owner⟧
© www.soinside.com 2019 - 2024. All rights reserved.