Skip to content

Added regex backreference #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<pre>
"/([a-z])\1/g" => Ha<a href="#learn-regex"><strong>pp</strong></a>ine<a href="#learn-regex"><strong>ss</strong></a>. </pre>


[Test the regular expression](https://regex101.com/r/5Nclso/1)

<pre>
"/(\")(.*?)\1/" => He said "<a href="#learn-regex"><strong>She's beautiful</strong></a>" </pre>


[Test the regular expression](https://regex101.com/r/ykVPb4/1)


## Contribution

Expand Down