. When matching string patterns using regular expressions, you might wish to match the same piece of text more than once.When the pattern used to perform the first match includes non-literal elements, you can look for the repeated text using a backreference.A backreference in a regular expression identifies a previously matched group and looks for exactly the same text again. In a given test string, replace all occurrences of two digits with a hyphen '-', followed by those digits, followed by another hyphen, followed by a space. Backreference by name: \k If a regexp has many parentheses, it’s convenient to give them names. For example, in the string "There were two logos", the matches shall be "There were two logos". Now it works! HOT QUESTIONS. In this chapter we shall specifically dig deeper into the former type, i.e capturing groups, and in the way understand the concept of backreferencing. As stated in the question, the replacement string consists of an opening parenthesis (, followed by the match, followed by a closing parenthesis ). It's now your time to tackle backreferencing! Use Tools to explore your results. In the example below the group with quotes is named ?