Hi, Mark Volkmann schrieb am 04.05.2015 um 12:39: > I don't see a builtin function to find the index of a substring within a > string. > Does that exist? > For example, I want something like index('foobarbaz', 'bar') to return 3. > It seems the index function works on lists, but not strings.
the function is called stridx(). Note that it returns the *byte* index. This might matter if you have encoding set to UTF-8 and the string in which you want to search contains non-ASCII letters before the first occurrence of the search string, e.g., :echo stridx('Jürgen', 'rg') prints 2 if encoding is set to latin1, but prints 3 if encoding is set to UTF-8. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin) -- -- 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 because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.