I have a text document like so:
<table width="10">
</table>
I open the document with 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 pattern found. I also tried this and it doens’t work:
0,$s/width="[0-9]+"//gc
This one below worked:
:0,$s/width="\d\d"//gc
What’s wrong with my first two expressions?
You have two errors in your regexp!
First, use
\dwithout[]s around it. You probably mix it with character classes like:alpha:,:digit:, etc.Second, Escape the
+sign. By default you should escape it.So your regexp would be:
And, please, read help before posting on stackoverflow:
You may also be interested in this help section: