A
A
albertalexandrov2018-07-26 12:30:21
Python
albertalexandrov, 2018-07-26 12:30:21

What does \1 mean in a regular expression?

Hello!
What does \1 mean in a regular expression ^\W\d{2}\s?\.([abc\d])\1\1$?
What !12.awill match \1 in the string?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2018-07-26
@albertalexandrov

\1 means backreference, that is, a reference to a group construct. In this case, your group is ([abc\d]), so \1 will denote what fell under this group (letter a,b,c or a number).
In your line !12.a it will be 'a'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question