admin管理员组

文章数量:1356808

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 badges
Add a comment  | 

1 Answer 1

Reset to default 4

No, 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