We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Regex
  3. Backreferences
  4. Forward References

Forward References

Problem
Submissions
Leaderboard
Discussions
Editorial

NOTE - Forward reference is supported by JGsoft, .NET, Java, Perl, PCRE, PHP, Delphi and Ruby regex flavors.

Forward reference creates a back reference to a regex that would appear later.
Forward references are only useful if they're inside a repeated group.
Then there may arise a case in which the regex engine evaluates the backreference after the group has been matched already.


Task

You have a test string .
Your task is to write a regex which will match , with following condition(s):

  • consists of tic or tac.
  • tic should not be immediate neighbour of itself.
  • The first tic must occur only when tac has appeared at least twice before.

Valid

tactactic
tactactictactic

Invalid

tactactictactictictac
tactictac

Note

This is a regex only challenge. You are not required to write any code.
You only have to fill the regex pattern in the blank (_________).

Author

[deleted]

Difficulty

Easy

Max Score

20

Submitted By

17756

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy