0

assume a regex like

(a|(?:))(b|(?:))(a|(?:))$

valid results are "a,b,ab,aba". But in the case "a" there are two possible matches, one for the first group and one for the last. Boost regex and std regex will return only one result for input "a". Is there any way to get access to the other solutions also?

Markus
  • 373
  • 1
  • 11
  • Please also show us the inputs which go along with the possible matches. – Tim Biegeleisen Jul 16 '20 at 06:03
  • The input with two matches is "a" .. this will hit the first group and the other two empty .. OR .. the last group with the first and second empty. But this regex is just a sample for the general question to get all possible matches – Markus Jul 16 '20 at 06:13
  • The way a regular expression is evaluated, a character in the input string can only be matched once. If you want it to hit on multiple groups, you will have to split the regex up and evaluate the possible matches one by one. – MarTim Jul 16 '20 at 07:57
  • Not sure how std and boost are implemented... but a backtrack based system may step back after a solution is found and try other branches also .. – Markus Jul 16 '20 at 18:57

0 Answers0