From c07416a8cde1f9b7718d2e2fa392d122bbce9382 Mon Sep 17 00:00:00 2001 From: Gzix-Joker Date: Tue, 30 Jun 2020 19:35:51 +0000 Subject: [PATCH] Added regex backreference --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 55da5ce..11aaacc 100644 --- a/README.md +++ b/README.md @@ -591,6 +591,21 @@ possible. We can use `?` to match in a lazy way, which means the match should be [Test the regular expression](https://regex101.com/r/AyAdgJ/2) +## 7. Backreferences +A backreference in a regular expression identifies a previously matched group and looks for exactly the same text again. A simple example of the use of backreferences is when you wish to look for adjacent, repeated words in some text. + +
+"/([a-z])\1/g" => Happiness. 
+ + +[Test the regular expression](https://regex101.com/r/5Nclso/1) + +
+"/(\")(.*?)\1/" => He said "She's beautiful" 
+ + +[Test the regular expression](https://regex101.com/r/ykVPb4/1) + ## Contribution