Saturday, December 23, 2023

Function to find all matches in a string?

I was looking for something similar to Python's re.findall()/finditer()
function to answer a question on Reddit[1] but was surprised I
couldn't find anything in

:help function-list

The general intent would be to take an input string and return a
List containing all the sub-strings matching a pattern like

let matches=findall('amwenxipyuqz', '[aeiou]')

would set matches to

['aw', 'en', 'ip', 'uq']

I was able to cobble together a hack-job in this case, but I'd hoped
to be able to do something like

:let a=[] | g/#\w\+/call extend(a, findall(getline('.'), @/))

Does such a function exist and I just missed it?

Thanks!

-tim

[1]
https://www.reddit.com/r/vim/comments/18pcd84/the_vim_way/kenedxq/





--
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ZYdgu8L-KK7n2ZbF%40thechases.com.

No comments: