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).
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/nx64l.png)
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:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/Pe0ov.png)
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.