gpt4 book ai didi

c++ - 是否可以在前瞻中使用 'Repeats' 来 boost :regex?

转载 作者:行者123 更新时间:2023-11-28 04:01:00 25 4
gpt4 key购买 nike

我正在尝试从嵌套在 block 中的 C++ 代码中提取一些变量。例如,如果我有

        DEL_TYPE_NONE,
DEL_TYPE_DONE,
DEL_TYPE_WAIT,

我要匹配:

“DEL_TYPE_NONE”
“DEL_TYPE_DONE”
“DEL_TYPE_WAIT”

我的图案是这样的:

std::string pat("(?<=^[\\t]?)[A-Z0-9_]+(?=,$)");

但是当编译器试图读取我的模式时,我不断收到错误消息。我不明白,但是 有问题吗?在\\t之后标记?如果我摆脱?标记然后它编译并只找到 "DEL_TYPE_WAIT"

为什么我不能在 Lookahead 中使用 Repeats?接下来我可以尝试什么?

最佳答案

我找到了答案。 没有来自这个manual

Lookbehind

(?<=pattern) consumes zero characters, only if pattern could be matched against the characters preceding the current position (pattern must be of fixed length).

关于c++ - 是否可以在前瞻中使用 'Repeats' 来 boost :regex?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/539939/

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