Your regex does not work because (\d)\s
matches and captures a digit and then matches a any vertical or horizontal whitespace including line breaks. The replacement is the whole match and a '
char. Thus, you append '
to any digit + whitespace sequence that affects the digit chunks at the end of the second column.
To add '
to the digit chunk at the start of the line you may use
^'\d+
and replace with $0'
.
Details
^
- start of the line anchor
'
- a single quote
\d+
- 1 or more digits.
The replacement is the whole match value ($0
) and a '
(basically, we append '
to each match).
An alternative approach is to insert '
in between a digit and a horizontal whitespace:
(\d)(\h)
and replace with $1'$2
. It will append '
to all non-final digit chunks on a line:
Details
(\d)
- Capturing group 1 (later referenced to with $1
placeholder): a digit
(\h)
- Capturing group 2 (later referenced to with $2
placeholder): a horizontal whitespace.