I'm trying to determine how many #
characters are at the beginning of a line.
In perl, I can so something like this:
$match =~ m/^(#+)[^#])/;
$length = length $1;
Trying to do something similar in vim:
getline(a:lnum) =~ '\v^(#+)[^#]'
let length = strlen \1
I believe the \v
allows me to write a regex like perl, correct?
I'm just not sure if I can do capturing like I'm doing here or not.
\v
does not mean perl regex; it means very-magic vim regex. In practice you can do all the same things, but the syntaxes differ at points. Check the help for that. Then check the help formatch()
,substitute()
, andsubmatch()
– D. Ben Knoble♦ Apr 27 '19 at 19:31:h submatch()
? That should give you enough to experiment and self-answer. – D. Ben Knoble♦ Apr 27 '19 at 19:49