I have the following code:
echo "12. Chapter Name" | sed -n -E "s/([0-9]{2})\.[[:space:]].*/\1/p"
It prints 12
as expected, since \1
refers to the first capturing group.
However, if \0
is used instead of \1
, the output is 12. Chapter Name
, the entire input string is printed.
It seems that as long as the regex found a match, \0
prints the entire input string. Is this correct?
I'm running Debian 10.2.