re

01.06 Capturing Groups and Back References

Capturing Groups

(\d)\d\1

The \1 refers back to what was captured in the group enclosed by parentheses. If you have more than one Capturing Group, using \1, \2 as sequence referring.

Match the whole number 707-827-7019

Notice there’re four 7 in the number, so below we capture first 7, and refer it three times using Back References

(d)0\1\D\d\d\1\D\1\d\d\d

Date: 2025/04/28