> Hi, all.
>
> I'm trying to build a function that separates file names from full
> paths. I was using matchstr() function but there is a problem. It
> doesn't return anything. For example:
>
> :echo matchstr("~/.vim/atpl/class.h", "/\w\+\.h$")
The problem is with the backslashes inside double quotes being chewed
up.
To see what's happening, do:
:echo "/\w\+\.h$"
echoes:
/w+.h$
So, the pattern you're matching against is slash, followed by one or
more w's, followed by any character ('.' without a backslash), ending
with 'h'.
See:
:help usr_41 -- search for /double quote
:help expr-quote
To avoid the issue, it's generally easiest to use single quotes:
:echo matchstr('~/.vim/atpl/class.h', '/\w\+\.h$')
echoes:
/class.h
--
Best,
Ben
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment