What happened to my REGEX when using the VI editor?
I have a text document:
<table width="10">
</table>
I am opening a document using the VI editor. I want to replace all instances of width = "somenumber" with nothing. I issue this command in the VI editor:
:0,$s/width="[\d]+"//gc
VI says no template found. I've also tried this and it doesn't work:
0,$s/width="[0-9]+"//gc
Below is the following:
:0,$s/width="\d\d"//gc
What happened to my first two expressions?
source to share
There are two in your regexp !
Use \d
without []
around it first. You are probably confusing it with character classes like :alpha:
, :digit:
etc.
Second, run the sign +
. By default, you should avoid this.
So your regex would be:
:0,$s/width="\d\+"//gc
And please read the help before posting to stackoverflow:
:h :s
You may also be interested in this help section:
:h magic
source to share