Thamizhiniyan C S
HomeWriteupsResourcesCheatsheets
HackerRank
HackerRank
  • HackerRank
  • Linux Shell
    • Bash
    • Text Processing
      • Cut
      • Head
      • Middle
      • Tail
      • Tr
      • Sort
      • Uniq
      • Paste
    • Arrays In Bash
    • Grep Sed Awk
      • Grep
      • Sed
      • Awk
  • Regex
    • Introduction
    • Character Class
    • Repetitions
    • Grouping and Capturing
    • Backreferences
    • Assertions
    • Applications
  • Python
    • Introduction
    • Basic Data Types
    • Strings
    • Sets
    • Math
    • Itertools
    • Collections
    • Date and Time
    • Errors and Exceptions
    • Classes
    • Built-Ins
    • Python Functionals
    • Regex and Parsing
    • XML
    • Closures and Decorators
    • Numpy
    • Debugging
  • C
    • Introduction
    • Conditionals and Loops
    • Arrays and Strings
Powered by GitBook
On this page
  • Matching Same Text Again & Again
  • Backreferences to Failed Groups
  • Branch Reset Groups
  • Forward References

Was this helpful?

  1. Regex

Backreferences

PreviousGrouping and CapturingNextAssertions

Last updated 1 year ago

Was this helpful?

Matching Same Text Again & Again

([a-z]\w\s\W\d\D[A-Z][a-zA-Z][aeiouAEIOU]\S)\1

Backreferences to Failed Groups

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

  • S consists of 8 digits.

  • S may have "-" separator such that string S gets divided in 4 parts, with each part having exactly two digits. (Eg. 12-34-56-78)

^\d{2}(-?)\d{2}\1\d{2}\1\d{2}$

Branch Reset Groups

^\d{2}(-(?:--)?|\.|:)\d{2}\1\d{2}\1\d{2}$

Forward References

^(\2tic|(tac))+$
Solve Programming Questions | HackerRankHackerRank
Logo