Hi, thank you all. Off course. I was so ansious to finish the function that I didn't notice this fault.
Thank you all guys, Alessandro Antonello 2011/2/17 Benjamin R. Haskell <[email protected]>: > On Thu, 17 Feb 2011, Alessandro Antonello wrote: > >> 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 > -- 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
