gpt4 book ai didi

python - 将 C++ Boost 正则表达式转换为 Python 正则表达式

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:43:29 32 4
gpt4 key购买 nike

<分区>

目的是将这些 C++ boost 中的正则表达式转换为 Python re 正则表达式:

  typedef boost::u32regex tRegex;

tRegex emptyre = boost::make_u32regex("^$");
tRegex commentre = boost::make_u32regex("^;.*$");
tRegex versionre = boost::make_u32regex("^@\\$Date: (.*) \\$$");
tRegex includere = boost::make_u32regex("^<(\\S+)$");
tRegex rungroupre = boost::make_u32regex("^>(\\d+)$");
tRegex readreppre = boost::make_u32regex("^>(\\S+)$");
tRegex tokre = boost::make_u32regex("^:(.*)$");
tRegex groupstartre = boost::make_u32regex("^#(\\d+)$");
tRegex groupendre = boost::make_u32regex("^#$");
tRegex rulere = boost::make_u32regex("^([!-+^])([^\\t]+)\\t+([^\\t]*)$");

我可以一个一个地重写这些正则表达式,但上面的例子还有很多,所以我的问题是关于

  • 如何将 C++ boost regexest 转换为 Python
  • boost 正则表达式和 python re 正则表达式有什么区别?

C++ boost::u32regex 是否与 python 中的 re 正则表达式相同? 如果不是,有什么区别? (非常感谢链接到文档 =))例如:

  • 在boost中,有boost::u32regex_match,是不是和重新匹配?
  • 在 boost 中,有 boost::u32regex_search,它与 re.search 有何不同?
  • 还有 boost::format_perlboost::match_defaultboost::smatch,它们在 python 中的等价物是什么 重新?

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