简体   繁体   English

将 ASN.1 字符串与 python regexp 匹配

[英]Matching ASN.1 string with python regexp

How can I match this ASN.1 string with python regexp如何将这个 ASN.1 字符串与 python regexp 匹配

"::= { bgpPathAttrEntry 6 }"

I try this regexp:我试试这个正则表达式:

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

and fail.并失败。

You can use您可以使用

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

See the regex demo查看正则表达式演示

Details细节

  • ::= - a literal substring ::= - 文字子串
  • \\s*{\\s* - a { char enclosed with zero or more whitespace chars \\s*{\\s* - 用零个或多个空格字符括起来的{字符
  • (?P<entry>[^{}]*?) - Group "entry": any 0 or more chars other than { and } , but as few as possible (?P<entry>[^{}]*?) - 组“entry”:除{}之外的任何 0 个或更多字符,但尽可能少
  • \\s* - zero or more whitespace chars \\s* - 零个或多个空白字符
  • } - a } char. } - 一个}字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM