admin 管理员组文章数量: 1086019
Is it possible to tell std::regex_match
to ignore particular character(s) in back references?
For example, I may want to ignore @
and expect "([a-z]*@[a-z]*)\1"
to match "foo@barfoobar"
.
If not (I suspect that it's not possible), what would be another way of solving this problem?
Is it possible to tell std::regex_match
to ignore particular character(s) in back references?
For example, I may want to ignore @
and expect "([a-z]*@[a-z]*)\1"
to match "foo@barfoobar"
.
If not (I suspect that it's not possible), what would be another way of solving this problem?
Share Improve this question edited Mar 27 at 19:06 Remy Lebeau 601k36 gold badges507 silver badges851 bronze badges asked Mar 27 at 18:58 DYZDYZ 57.2k10 gold badges72 silver badges99 bronze badges1 Answer
Reset to default 4No, there's no way to ignore part of the back-reference. The solution is to split the match into two capture groups so you don't include the unwanted character in the back-reference.
([a-z]*)@([a-z]*)\1\2
本文标签: cRegex Ignoring characters in backreferencesStack Overflow
版权声明:本文标题:c++ - Regex: Ignoring characters in backreferences - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744072647a2528770.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论