0

I need to match on the below pattern and I am trying to write a Regex in Re2, In PCRE the below Regex works fine but this does not work in Re2 Regex type as back reference is not supported in Re2.

^([A-Za-z0-9])\1+-([A-Za-z0-9])\2+-([A-Za-z0-9])\3+-([A-Za-z0-9])\4+-([A-Za-z0-9])\5+$

Is there a way to do the same thing in Re2 regex. I need to match on below patterns strictly. i.e. It should match on the same character any number of times. sth like as below

AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA
BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB
AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEEEE
aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
11111111-1111-1111-1111-111111111111
22222222-1111-3333-4444-666666666666
aaaaaaaa-CCCC-1111-2222-DDDDDDDDDDDD
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Vicky
  • 35
  • 2
  • 7
  • *[RE2 cannot support backreferences without compromising its principles.](https://github.com/google/re2/issues/101#issuecomment-233561994)* You will have to explicitly repeat each letter/digit, which is rather insane. What is your programming environment? – Wiktor Stribiżew Jul 08 '20 at 09:08
  • My programming environment is Go Lang – Vicky Jul 08 '20 at 09:14

0 Answers0