String delete in VIM
I have a file that has the general form as
number,number,string
and i want to delete both the numbers from each line and extract only the string. What would the regexp b开发者_StackOverflow中文版e?
You can use:
:s/^[0-9]*,[0-9]*,//
For the whole file, that's:
:%s/^[0-9]*,[0-9]*,//
A good regular expression may be:
/^\(\s*[+-]*[[:digit:]]*\.*[[:digit:]]\+,\s*\)\{2}/
This will match numbers, including an optional sign and an optional decimal point (assuming you use .
in your locale) followed by a comma and optional whitespace twice at the beginning of the line.
Usage:
:%s/^\(\s*[+-]*[[:digit:]]*\.*[[:digit:]]\+,\s*\)\{2}//
Add hex digits ([[:xdigit:]]
) to taste.
精彩评论