Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
tlrobinson
on Nov 30, 2014
|
parent
|
context
|
favorite
| on:
Regex Crossword
It's a backreference to the first capture group, which is denoted by the first set of parenthesis, e.x.
(.*)+\1
would match "ABAB", or "ABCABC", etc.
"\2" would match the second capture group, e.x.
(.*)(.*)\2\1
would match "ABBA", or "AABBBBAA", etc.
Edmontonian
on Nov 30, 2014
[–]
so in your first example, "AB" was in the capture group and the \1 repeats it?
tlrobinson
on Nov 30, 2014
|
parent
[–]
Correct. The following
(.*)\1+
Would also match "ABABAB", for example.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
"\2" would match the second capture group, e.x.
would match "ABBA", or "AABBBBAA", etc.