I am working on an exercise on regex forward reference like the one asked here
The task is:
I've used this regex to solve it. But it doesn't use forward reference so I really want to know how this can be solved using it.
^tac(tac)+(tic(tac)+){0,}(tic)?$
Valid:
tactactic
tactactictactic
Invalid:
tactactictactictictac
tactictac
How do I solve this problem?
This uses a forward reference:
^(\2tic|(tac))+$
It's actually very similar to the example given on this page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With