gpt4 book ai didi

python - 将 ASN.1 字符串与 python 正则表达式匹配

转载 作者:行者123 更新时间:2023-12-05 07:01:46 24 4
gpt4 key购买 nike

如何将这个 ASN.1 字符串与 python regexp 匹配

"::= { bgpPathAttrEntry 6 }"

我试试这个正则表达式:

\s+::=\s*{\s*(?P<entry>\S+\s\d+)}\n

然后失败。

最佳答案

你可以使用

::=\s*{\s*(?P<entry>[^{}]*?)\s*}

参见 regex demo

详情

  • ::= - 文字子串
  • \s*{\s* - 一个 {包含零个或多个空白字符的字符
  • (?P<entry>[^{}]*?) - 组“条目”:{ 以外的任何 0 个或多个字符和 } , 但越少越好
  • \s* - 零个或多个空白字符
  • } - 一个 }字符。

关于python - 将 ASN.1 字符串与 python 正则表达式匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63747692/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com