0

Here is an example regex which uses a capture group and backreference:

<tag-([1-9])></tag-\\1>

It looks like that backreferences require a capture group so the following regex is incorrect:

<tag-(?:[1-9])></tag-\\1>

I would like to have the same result as when using backreferences but without creating a capture group ? Is there any workaround ?

Irbis
  • 1,043
  • 4
  • 21
  • 1
    Not that I'm aware of. Why don't you want to have a capturing group? – sp00m Apr 09 '19 at 16:54
  • I use boost_regex, in more complex expressions I need to have numerical indices which refers to capture groups and it doesn't look good to me, so I try to keep a number of capture group as minimal as possible. – Irbis Apr 09 '19 at 17:06
  • No, that's what capture groups are for. "More complex expressions" might not be a good thing anyways. – L3viathan Apr 09 '19 at 17:10

0 Answers0