News for hackers. Stuff that matters.
Re:Regex Crossword by Edmontonian on Saturday November 29, 2014 @07:10PM (#8675497)
What does it mean when a reg ex ends with a `\1` (backslash 1) as in this example third beginner puzzle? (.)+\1

http://regexcrossword.com/challenges/beginner/puzzles/3

Re:Regex Crossword by tlrobinson on Saturday November 29, 2014 @07:18PM (#8675513)
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.
Re:Regex Crossword by Edmontonian on Saturday November 29, 2014 @07:37PM (#8675562)
so in your first example, "AB" was in the capture group and the \1 repeats it?
Re:Regex Crossword by tlrobinson on Saturday November 29, 2014 @08:13PM (#8675633)
Correct. The following

    (.*)\1+
Would also match "ABABAB", for example.
Re:Regex Crossword by Ygg2 on Sunday November 30, 2014 @05:17AM (#8676497)
Speaking of that puzzle how come [COBRA]+ and (.)+\1 give back result 'O'? Why not C or B or A?
Re:Regex Crossword by cyborgx7 on Sunday November 30, 2014 @08:02AM (#8676725)
(.)+\1 means the last letter has to be equal to the first letter.

(AB|O|OR)+ dictates that the last letter of the first row has to be A or O

[^ABRC]+ makes it so that the lower right square can't be B therefore the upper right square can't be A

Re:Regex Crossword by eru on Saturday November 29, 2014 @07:25PM (#8675533)
Look at the Help button (top right); that explains all their syntax.
Re:Regex Crossword by Edmontonian on Saturday November 29, 2014 @07:37PM (#8675559)
The help button doesn't really explain that point ( I don't think) at least not in a very clear way for someone inexperienced with regex