:'<,'>s/[^\d]*/
will replace all char
how to replace all non-number char ?
You can use [^0-9]
instead of [^\d]
. [^\d]
is not replacing all characters, it is replacing all but d
.
Solution:
:'<,'>s/[^0-9]*//g
2 Likes
Many character classes classes can be negated by using an uppercase letter. In this case \d
is equivalent to [0-9]
and \D
is equivalent to [^0-9]
.
The other character classes that can be negated this way are listed in the docs.
1 Like