我想修剪以下字符串:
<tab>PACKAGE MAIN(字符串以制表符空格开头)
目标只是获得PACKAGE MAIN输出。
我已经尝试过以下VIM带有参数的函数
let line = substitute (line, '\t+(.*)' , '\1', 'g')
let line = substitute (line, '\t+\(.*\)' , '\1', 'g')
let line = substitute (line, '\t\+\(.*\)' , '\1', 'g')
let line = substitute (line, '[\s\t]+\(.*\)', '\1', 'g')
Run Code Online (Sandbox Code Playgroud)
(以及更多)
VIM正则表达式匹配函数中的字符<tab>或<space>(空白)字符的准则是什么substitute?
最后一项稍微修改一下:
substitute (line, '[ \t]\+\(.*\)', '\1', 'g')
Run Code Online (Sandbox Code Playgroud)
+必须在前面加上\才能获得神奇的含义。您可以使用\s任何空格,而不是[ \t]只匹配空格和制表符。