Marc Weber wrote:
When doing something like
map(["a","b"],"matchstr(v:val, "\(.\)"))
will the regular expression "\(.\)" be compiled on every iteration?
How about this:
for l in lines
if l =~"regex"
...
?
I noticed this beeing slow compared to executing grep once ago.
If this is an issue, there might be the solution introducing a compiled
regular expression as used in python additional to Number, String,
Funcref, List, Dictionary
What do you think? Would this be an enhancement?
Marc Weber
\(.\) is equivalent to . in this case. \(\) is never necessary around the
whole pattern; in a substitute, \(.\) can be useful as part of a larger
pattern if you want to refer to it as \1 to \9 or via submatch().
About a compiled regular expression type, I don't think it would be useful
since we already have :g and :vimgrep. IMO the bigger overhead in your example
is in the "for" and "if" constructs.
Best regards,
Tony.